NIHVIVO-747 Apply client-side autocomplete filtering to add authors form
This commit is contained in:
parent
8d5e7a2dc0
commit
ade800e2d4
1 changed files with 2 additions and 24 deletions
|
@ -68,7 +68,6 @@ public class AutocompleteController extends FreeMarkerHttpServlet implements Sea
|
||||||
private static final Log log = LogFactory.getLog(AutocompleteController.class);
|
private static final Log log = LogFactory.getLog(AutocompleteController.class);
|
||||||
|
|
||||||
private static String QUERY_PARAMETER_NAME = "term";
|
private static String QUERY_PARAMETER_NAME = "term";
|
||||||
private static String EXCLUDE_URI_PARAMETER_NAME = "excludeUri";
|
|
||||||
|
|
||||||
private IndexSearcher searcher = null;
|
private IndexSearcher searcher = null;
|
||||||
String NORESULT_MSG = "";
|
String NORESULT_MSG = "";
|
||||||
|
@ -122,16 +121,7 @@ public class AutocompleteController extends FreeMarkerHttpServlet implements Sea
|
||||||
String qtxt = vreq.getParameter(QUERY_PARAMETER_NAME);
|
String qtxt = vreq.getParameter(QUERY_PARAMETER_NAME);
|
||||||
Analyzer analyzer = getAnalyzer(getServletContext());
|
Analyzer analyzer = getAnalyzer(getServletContext());
|
||||||
|
|
||||||
// Get the list of individual uris that should be excluded from the search
|
Query query = getQuery(vreq, portalFlag, analyzer, indexDir, qtxt);
|
||||||
String filters[] = vreq.getParameterValues(EXCLUDE_URI_PARAMETER_NAME);
|
|
||||||
List<String> urisToExclude = null;
|
|
||||||
if (filters != null) {
|
|
||||||
urisToExclude = Arrays.asList(filters);
|
|
||||||
}
|
|
||||||
|
|
||||||
//boolean tokenize = "true".equals(vreq.getParameter("tokenize"));
|
|
||||||
|
|
||||||
Query query = getQuery(vreq, portalFlag, analyzer, indexDir, qtxt, urisToExclude);
|
|
||||||
log.debug("query for '" + qtxt +"' is " + query.toString());
|
log.debug("query for '" + qtxt +"' is " + query.toString());
|
||||||
|
|
||||||
if (query == null ) {
|
if (query == null ) {
|
||||||
|
@ -215,7 +205,7 @@ public class AutocompleteController extends FreeMarkerHttpServlet implements Sea
|
||||||
}
|
}
|
||||||
|
|
||||||
private Query getQuery(VitroRequest request, PortalFlag portalState,
|
private Query getQuery(VitroRequest request, PortalFlag portalState,
|
||||||
Analyzer analyzer, String indexDir, String querystr, List<String> urisToExclude) throws SearchException{
|
Analyzer analyzer, String indexDir, String querystr) throws SearchException{
|
||||||
|
|
||||||
Query query = null;
|
Query query = null;
|
||||||
try {
|
try {
|
||||||
|
@ -244,18 +234,6 @@ public class AutocompleteController extends FreeMarkerHttpServlet implements Sea
|
||||||
query = boolQuery;
|
query = boolQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Uris that should be excluded from the results
|
|
||||||
if (urisToExclude != null) {
|
|
||||||
for (String uri : urisToExclude) {
|
|
||||||
BooleanQuery boolQuery = new BooleanQuery();
|
|
||||||
boolQuery.add( query, BooleanClause.Occur.MUST);
|
|
||||||
boolQuery.add( new TermQuery(
|
|
||||||
new Term(Entity2LuceneDoc.term.URI, uri)),
|
|
||||||
BooleanClause.Occur.MUST_NOT);
|
|
||||||
query = boolQuery;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//if we have a flag/portal query then we add
|
//if we have a flag/portal query then we add
|
||||||
//it by making a BooelanQuery.
|
//it by making a BooelanQuery.
|
||||||
Query flagQuery = makeFlagQuery( portalState );
|
Query flagQuery = makeFlagQuery( portalState );
|
||||||
|
|
Loading…
Add table
Reference in a new issue