Closed ramon-tomas-c closed 8 years ago
Hi, thanks for reporting this.
Would you be able provide a sample JSON object demonstrating the problem?
Yes, sure.
I have no problem when I try to add other parameters such as filter, orderby, select, .. as they all are comma separated. But when it comes to facets, they have to be inserted as { facet=facetA, facet=facetB , .. }
client.search(indexName, queryBuilder, function (err, results, raw)
function queryBuilder(content, predicate, suggesterName) { var result = {}; result.search = content ? content : '*';
for (var propertyName in predicate) {
var obj = predicate[propertyName];
if (ko.isObservable(obj) && (!obj() || obj().length === 0)) {
continue;
}
switch (propertyName) {
case constants.predicateTypes.filter:
result.$filter = predicate.filter().toODataFragment();
break;
case constants.predicateTypes.orderBy:
result.$orderby = predicate.orderBy().join(",");
break;
case constants.predicateTypes.select:
result.$select = predicate.select().join(",");
break;
case constants.predicateTypes.highlight:
result.highlightPreTag = "<b>";
result.highlightPostTag = "</b>";
result.highlight = predicate.highlight().join(",");
break;
**case constants.predicateTypes.facets:
result.facet = facetA;
result.facet = facetB;
break;**
case constants.predicateTypes.isInlineCount:
result.$count = predicate.isInlineCount();
break;
case constants.predicateTypes.skip:
result.$skip = predicate.skip();
break;
case constants.predicateTypes.take:
result.$top = predicate.take();
break;
}
}
return result;
}
I see what you mean. This is an interesting problem. Could this be solved with an approach like this:
var result = { facet:"A", facet:"B"}
Javascript appears to only use the last provided definition for a property.
So, var result = { facet:"A", facet:"B"}
will result in the object { facet: "B" }
.
@glombek yes, this is a limitation of JSON. I'll need to do some plumbing to work around it...
Hello,
When adding the json object with parameters in the search call, you cannot add multiple facets in json.
Regards.