List<JSONObject> results = index.search("Oracle database profit");The result array is sorted in descencing order, sorted by the score. Each result is a
JSONObject
with the following fields: List<JSONObject> results = index.search("Oracle database profit"); JSONObject result = results.get(0); float score = result.getFloat("score"); String ref = result.getString("ref");ref will be equal to "1", so will refer to the document with the id "1".
index.search("Oracle database profit", "{fields: {title: {boost: 2}, body: {boost: 1}}}");
index.search("database profit", "{bool: AND}"):The boolean model can be specified separately for each field. For example:
index.search("Oracle database profit", "{fields: {title: {bool: OR}, body: {bool: AND}}}");
JSONObject doc1 = new JSONObject(); doc1.put("id", 1); doc1.put("title", "Oracle released its latest database Oracle 12g"); doc1.put("body", "Yestaday Oracle has released its new database Oracle 12g, this would make more money for this company"); index.addDoc(doc1);By default you will not have any result if you perform the following search:
index.search("Ora");However it is possible to allow to expand the search terms. For example, the following search will return one result with the example document:
index.search("Ora", "{expand: true}");Note that the query results from expanded tokens are penalized because they are not exactly the same as the query token.
index.search("Oracle database profit", "{fields: {title: {expand: false}, body: {expand: true}}}");
Copyright 2017 Wei Song. Copyright 2018 Herve Girod. All Rights Reserved. Documentation and source under the MIT licence