REPO-1154: added trem as text in lucene search

This commit is contained in:
Andreea Nechifor
2017-10-25 12:39:02 +03:00
parent 0e1006cae1
commit b42dc86bac
2 changed files with 40 additions and 1 deletions

View File

@@ -189,7 +189,12 @@ public class QueriesImpl implements Queries, InitializingBean
NodeRef nodeRef = nodes.validateOrLookupNode(rootNodeId, null);
query.append("PATH:\"").append(getQNamePath(nodeRef.getId())).append("//*\" AND (");
}
query.append(term);
if (term != null)
{
query.append("\"");
query.append(term);
query.append("\"");
}
if (rootNodeId != null)
{
query.append(")");

View File

@@ -86,6 +86,40 @@ public class QueriesNodesApiTest extends AbstractSingleNetworkSiteTest
return result;
}
@Test
public void testSearchTermWhiteSpace() throws Exception{
setRequestContext(user1);
String myFolderNodeId = getMyNodeId();
String parentTerm = createFolder(myFolderNodeId, "folder term1").getId();
String childTerm = "find" + Math.random();
String childTermWS = childTerm + " " + "find";
Map<String,String> docProps = new HashMap<>(2);
docProps.put("cm:title", childTerm);
docProps.put("cm:description", childTerm);
createTextFile(parentTerm, childTerm, childTerm, "UTF-8", docProps);
docProps.put("cm:title", childTermWS);
docProps.put("cm:description", childTermWS);
createTextFile(parentTerm, childTermWS, childTermWS, "UTF-8", docProps);
Paging paging = getPaging(0, 100);
HashMap<String,String> params = new HashMap<>(1);
params.put(Queries.PARAM_TERM, childTerm);
HttpResponse response = getAll(URL_QUERIES_LSN, paging, params, 200);
List<Node> nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
assertEquals(2, nodes.size());
params.put(Queries.PARAM_TERM, childTermWS);
response = getAll(URL_QUERIES_LSN, paging, params, 200);
nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
assertEquals(1, nodes.size());
}
/**
* Tests basic api for nodes live search - metadata (name, title, description) &/or full text search of file/content
*