@nelsonxx1 I’m not sure I entirely understand your question here.
Search requests that involve facets are not supported from N1QL. FTS only forwards the “hits” part from the search response to the N1QL engine. For facetted search requests, you should go directly to the search service (via REST or SDK) - Search Request | Couchbase Docs
If you’re having trouble with the SDK, I’d refer you to our SDK experts on this - #python-sdk .
@abhinav
Ok I want the results of a search with FTS to have Facets Fields that count the number of records that are the same. The whole field, not participating.
Example
Record 1
Record 2
Record 2
Record 3
Result:
Record 1: count 1
Record 2: count 2
Record 3: count 1
Ok, let’s say fieldX is the field name that holds “Record …” for every document.
Based on the data you have, I’d recommend indexing the “fieldX” using the keyword analyzer within your index - include doc values for it.
@abhinav
It is possible to use more than an Analyzer in the same field and in the same FTS index ?? For Faces fields use the keyword, but at the same time the data can be filtered with separate words by blank spaces, point, coma, etc …
Yes that’s possible. You will need to use the “searchable as” option to set a field alias. The field aliases will need to be unique within a type mapping.
fieldX with analyzer1 and make it searchable as “fieldX-1”
fieldX with analyzer2 and make it searchable as “fieldX-2”
As long as you search against those chosen AnySuitableSearchName-N, it would use the specified analyzer for that query as long as it is a non-analytic query in FTS.
I was testing the facet option and it works fine, but is it possible to add the total amount of facet responses? for no to add a size: 9999999999, I see that you do the tour of all the records, could this answer be included in the out of the facet field?
The total attribute of the facet result indicates the number of records that have been accounted for in the generated facets (based on the size).
We mean for users to set size to obtain the top-N facets. The only way to emit all the facets there are - is by choosing a large enough size and hoping that it’s greater than the number of facets.
with sql it would be something like this, but it takes too long time.
SELECT COUNT(1) FROM
(SELECT fpol, COUNT(1) AS count
FROM bills AS b
LET fmeta = SEARCH_META(b)
WHERE SEARCH(b,
{
"fields": [
"foreign_port_of_lading_name"
],
"query": {
"conjuncts": [
{
"inclusive_start": true,
"inclusive_end": true,
"field": "actual_arrival_date",
"start": "2020-01-01",
"end": "2020-01-31"
},
{
"field": "foreign_port_of_lading_name",
"match_phrase": "china"
}
]
}
},
{"index": "index_table3"}
)
GROUP BY fmeta.fields.foreign_port_of_lading_name AS fpol) AS v