Hi,
I’m sharing partial of my product model.
In search I need to get facets of attributes like;
I that possible?
Or how can I handle this?
Thanks
Hi,
I’m sharing partial of my product model.
In search I need to get facets of attributes like;
I that possible?
Or how can I handle this?
Thanks
Not sure how you would do it with Search
But the same result can be achieved using GROUP BY clause
SELECT a.attributeValueId, count(*) as count FROM `prac` p UNNEST p.attributes a GROUP BY a.attributeValueId;
I want to use SEARCH service because of I have dynamic query cant handled with indexes.
So I need to handle with facets.
Thanks.
@orhan With couchbase search (FTS) you will be able to build facets over textual or numeric fields as documented here - Search Facets | Couchbase Docs
It seems to me you’re trying to build facets over entire sub objects which is not possible.
If you index the 2 productIds you’ve shared above as separate documents, what is possible is running a query like this …
{
"query": {
"match_all": {
}
},
"facets": {
"attributeName": {
"size": 5,
"field": "attributes.attributeName"
},
"attributeValueName": {
"size": 5,
"field": "attributes.attributeValueName"
}
}
}
which would return a response like this …
{
"query": {
...
},
...
"facets": {
"attributeName": {
"field": "attributes.attributeName",
"total": 4,
"missing": 0,
"other": 0,
"terms": [
{
"term": "color",
"count": 2
},
{
"term": "model",
"count": 2
}
]
},
"attributeValueName": {
"field": "attributes.attributeValueName",
"total": 4,
"missing": 0,
"other": 0,
"terms": [
{
"term": "black",
"count": 2
},
{
"term": "t1001",
"count": 1
},
{
"term": "t1002",
"count": 1
}
]
}
}
}
Not sure if this is something you can work with though.
Hi @abhinav ,
if I spread to two facets then I cant find which attributeValue belongs to attributeName.
So I should handle them together.
Instead of storing your attributes as “objects” just store them as strings where each property of an attribute is delimited by, say, a pipe:
‘myAttrs’: [‘3|colour|3140|black’,‘18|model|1764|t1001’]
Then just do a facet on myAttrs in your code. Then in your code, you could build the facets yourself.
Another thing you could do is just store the attribute ids, and then look up the data for each attribute in some other collection/bucket/datastore/whatever (this would be slower, but if you cachedthe data it would probably be fine)
I recently used couchbae fts to implement ecommerce search, so i can help you if you want. We have dynamic facets, etc, so it’s the same as your use case.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.