Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.

Fulltext searches in Domino return a score (available as Document.FTS… #56

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ protected void writeEntry(JsonWriter jwriter, Document document
writeProperty(jwriter, RestServiceConstants.ATTR_UNID, unid);
String link = _uri + unid;
writeProperty(jwriter, RestServiceConstants.ATTR_HREF, link);
int score = document.getFTSearchScore();
if (score != 0) {
writeProperty(jwriter, RestServiceConstants.ATTR_SCORE, score);
}
} finally {
jwriter.endArrayItem();
jwriter.endObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import static com.ibm.domino.services.rest.RestServiceConstants.ATTR_MODIFIED;
import static com.ibm.domino.services.rest.RestServiceConstants.ATTR_NOTEID;
import static com.ibm.domino.services.rest.RestServiceConstants.ATTR_PARENTID;
import static com.ibm.domino.services.rest.RestServiceConstants.ATTR_SCORE;
import static com.ibm.domino.services.rest.RestServiceConstants.ATTR_TYPE;
import static com.ibm.domino.services.rest.RestServiceConstants.ATTR_UNID;
import static com.ibm.domino.services.rest.RestServiceConstants.ITEM_FILE;
Expand Down Expand Up @@ -175,6 +176,13 @@ protected void writeSystemItems(JsonWriter jsonWriter, int sysItem)
if ((sysItem & DocumentParameters.SYS_ITEM_AUTHORS)!=0) {
writeProperty(jsonWriter, ATTR_AUTHORS, document.getAuthors());
}
if ((sysItem & DocumentParameters.SYS_ITEM_SCORE)!=0) {
int score = document.getFTSearchScore();
// As this is always a new request/session, score seems always to be 0?
if (score != 0) {
writeProperty(jsonWriter, ATTR_SCORE, document.getFTSearchScore());
}
}
if ((sysItem & DocumentParameters.SYS_ITEM_FORM)!=0) {
String form = document.getItemValueString(ITEM_FORM);
if (form != null && form.length() > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,16 @@ protected void writeSystemColumns(JsonWriter jsonWriter, int syscol, RestViewNav
jsonWriter.endProperty();
}
}
if((syscol & ViewParameters.SYSCOL_SCORE)!=0) {
int score = navigator.getScore();
if(forceDefaultAttributes || score>0) {
jsonWriter.startProperty(ATTR_SCORE);
jsonWriter.outIntLiteral(score);
jsonWriter.endProperty();
}
}


}

protected void writeColumn(JsonWriter jsonWriter, RestViewNavigator navigator, int colIdx, String colName, Object colValue) throws IOException, ServiceException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class RestServiceConstants {
public static final String ATTR_CONTENT = "content"; //$NON-NLS-1$
public static final String ATTR_MESSAGE = "message"; //$NON-NLS-1$
public static final String ATTR_TYPE = "type"; //$NON-NLS-1$
public static final String ATTR_SCORE = "@score"; //$NON-NLS-1$

// View service attributes names used in JsonWriter
public static final String ATTR_ENTRYID = "@entryid"; //$NON-NLS-1$
Expand Down Expand Up @@ -144,6 +145,7 @@ public class RestServiceConstants {
public static final String ATTR_XML_COLUMNNUMBER = "columnnumber"; //$NON-NLS-1$
public static final String ATTR_XML_NAME = "name"; //$NON-NLS-1$
public static final String ATTR_XML_VIEWENTRIES = "viewentries"; //$NON-NLS-1$
public static final String ATTR_XML_SCORE = "score"; //$NON-NLS-1$
public static final String ATTR_XML_VIEWENTRY = ATTR_VIEWENTRY; //$NON-NLS-1$
public static final String ATTR_XML_ENTRYDATA = ATTR_ENTRYDATA; //$NON-NLS-1$
public static final String ATTR_XML_TEXT = ATTR_TEXT; //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public interface DocumentParameters extends DominoParameters {
public static final int SYS_ITEM_AUTHORS = 0x0020;
public static final int SYS_ITEM_HIDDEN = 0x0040;
public static final int SYS_ITEM_FORM = 0x0080;
public static final int SYS_ITEM_SCORE = 0x0100;
public static final int SYS_ITEM_ALL = 0xFFFFFFFF;

// Check
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public interface RestViewEntry {
public abstract int getDescendants() throws ServiceException;
public abstract int getChildren() throws ServiceException;
public abstract int getIndent() throws ServiceException;
public abstract int getScore() throws ServiceException;

// Column values
public abstract int getColumnCount() throws ServiceException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,16 @@ public void writeSystemIndent(int indent) throws IOException {
}
g.endProperty();
}
@Override
public void writeSystemScore(int score) throws IOException {
g.startProperty(ATTR_SCORE);
if(jsonTyped) {
g.outIntLiteral(score);
} else {
g.outStringLiteral(Integer.toString(score));
}
g.endProperty();
}

@Override
public void startEntryData() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ protected static abstract class LegacyWriter {
public abstract void writeSystemDescendants(int count) throws IOException;
public abstract void writeSystemChildren(int count) throws IOException;
public abstract void writeSystemIndent(int indent) throws IOException;

public abstract void writeSystemScore(int score) throws IOException;

public abstract void startEntryData() throws IOException;
public abstract void endEntryData() throws IOException;

Expand Down Expand Up @@ -182,8 +183,13 @@ private void writeViewEntry(LegacyWriter g, int syscol, boolean defColumns, List
g.writeSystemIndent(indent);
}
}


if((syscol & ViewParameters.SYSCOL_SCORE)!=0) {
int score = nav.getScore();
if(forceDefaultAttributes || score>0) {
g.writeSystemScore(score);
}
}

g.startEntryData();
// Read the default columns
int colidx = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public void recycle() {
public abstract int getDescendants() throws ServiceException;
public abstract int getChildren() throws ServiceException;
public abstract int getIndent() throws ServiceException;
public abstract int getScore() throws ServiceException;
public abstract String getForm() throws ServiceException;

// Column values
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,14 @@ public int getIndent() throws ServiceException {
}
}
@Override
public int getScore() throws ServiceException {
try {
return entry.getFTSearchScore();
} catch(NotesException ex) {
throw new ServiceException(ex,""); // $NON-NLS-1$
}
}
@Override
public boolean isDocument() throws ServiceException {
try {
return entry.isDocument();
Expand Down Expand Up @@ -376,6 +384,8 @@ protected NOINavigatorForDesign(View view, ViewParameters parameters) throws Not
@Override
public int getIndent() throws ServiceException {throw new IllegalStateException();}
@Override
public int getScore() throws ServiceException {throw new IllegalStateException();}
@Override
public int getColumnCount() throws ServiceException {throw new IllegalStateException();}
@Override
public String getColumnName(int index) throws ServiceException {throw new IllegalStateException();}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ public void writeSystemChildren(int count) throws IOException {
public void writeSystemIndent(int indent) throws IOException {
g.writeAttribute(ATTR_XML_INDENT,indent);
}
@Override
public void writeSystemScore(int score) throws IOException {
g.writeAttribute(ATTR_XML_SCORE,score);
}

@Override
public void startEntryData() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public interface ViewParameters extends DominoParameters {
public static final int SYSCOL_RESPONSE = 0x0400;
public static final int SYSCOL_HREF = 0x0800;
public static final int SYSCOL_LINK = 0x1000;
public static final int SYSCOL_SCORE = 0x2000;
//public static final int SYSCOL_ENTRYID = 0x2000;

public static final int SYSCOL_ALL = 0xFFFFFFFF;
Expand Down