Details
Description
Using the following node.js code:
server.route({
method: "GET",
path: "/facet/{searchTerm}",
handler: (request, response) => {
var terms = SearchQuery.match(""request.params.searchTerm"");
var query = SearchQuery.new("ftsProductDescription", terms);
var facet = SearchFacet.numeric("salesRanking",2);
facet.addRange("Top 100",1,101);
facet.addRange("Top 1000",101,1001);
query.addFacet("ranking", facet);
bucket.query(query, function(error, result, meta) {
if(error) {
return console.log("ERROR: ", error);
}
if(result.length > 0) {
console.log("FACETS: ", meta.facets["ranking"].numericRange);
}
for(var i = 0; i < result.length; i++) {
console.log("HIT: ", result[i].id);
}
response(result);
});
}
});
Receiving the following error:
ERROR: Error: An FTS error occured: rest_index: Query, indexName: ftsProductDescription, requestBody: {"ctl":{"timeout":75000},"facets":{"ranking":{"field":"salesRanking","numeric_ranges":[\{"end":100,"name":"Top 100","start":1},\{"end":1001,"name":"Top 1000","start":101}],"size":2,"indexName":"ftsProductDescription","query":{"match":"red"}}}}
, req: &http.Request{Method:"POST", URL*url.URL)(0xc42110f700), Proto:"HTTP/1.1", ProtoMajor:1, ProtoMinor:1, Header:http.Header{"User-Agent":[]string{"libcouchbase/2.8.3-njs couchnode/2.4.3 (node/9.4.0; v8/6.2.414.46-node.17; ssl/1.0.2n)"}, "Accept":[]string{"application/json"}, "Authorization":[]string{"Basic QWRtaW5pc3RyYXRvcjpwYXNzd29yZA=="}, "Content-Length":[]string{"242"}, "Content-Type":[]string{"application/json", Body:ioutil.nopCloser{Reader*bytes.Reader)(0xc421515980)}, GetBody:(func() (io.ReadCloser, error))(nil), ContentLength:242, TransferEncoding:[]string(nil), Close:false, Host:"127.0.0.1:8094", Form:url.Values{}, PostForm:url.Values{}, MultipartForm*multipart.Form)(nil), Trailer:http.Header(nil), RemoteAddr:"172.26.0.1:52724", RequestURI:"/api/index/ftsProductDescription/query", TLS*tls.ConnectionState)(nil), Cancel<-chan struct {})(nil), Response*http.Response)(nil), ctx*context.valueCtx)(0xc4215158f0)}, err: bleve: QueryBleve validating request, req: {"ctl":{"timeout":75000},"facets":{"ranking":{"field":"salesRanking","numeric_ranges":[\{"end":100,"name":"Top 100","start":1},\{"end":1001,"name":"Top 1000","start":101}],"size":2}},"indexName":"ftsProductDescription","query":{"match":"red"}}}}
, err: numeric range query must specify either min, max or both for range name 'Top 100'{{{{at /Users/peter.reale/Documents/Projects/ftsnodelab/node_modules/couchbase/lib/bucket.js:919:21 }}}}
Note that the start and end values are clearly defined and reflected in the returned search facet. Brett Lawson suspects that the problem is due to the parser expecting "min" and "max" range values while the SDK is sending them as "start" and "end". Thanks for your help.