Full text search array field

My document’s field looks like this.
“ancestors.code”:[“AS”, “307756”],

I want to bring it if it contains “AS”.
I’m not sure if this is possible.

If possible, I don’t know what “query type” is possible. “match” and “terms” didn’t work.

Hi @horoyoi_o,
I think there are a couple of issues here.

  1. “AS” being a stop word, its not getting indexed mostly. Without seeing the exact index definition its difficult to confirm. The default “Standard” tokeniser will drop the “AS” stop word token and hence queries won’t work.
  2. And I don’t think FTS supports dot (.) character in the field names during the indexing. It uses the dot based nomenclature for detecting the hierarchies during the query phase.

Try,

  1. Remove the (dot) from the field name, eg: ancestorscode or any name of your choice.
  2. Define a “Simple” analyser for the field to be indexed. Simple analysers will keep the stop words and match query should work.
    ref:https://docs.couchbase.com/server/6.5/fts/fts-using-analyzers.html#pre-constructed-analyzers

regards,

I do not understand. The other thing I run in exactly the same way as this works fine.

for example

“ancestors”: {
“dynamic”: true,
“enabled”: true,
“properties”: {
[
“country_code”: {
“dynamic”: false,
“enabled”: true,
“fields”: [
{
“analyzer”: “keyword”,
“include_in_all”: true,
“include_term_vectors”: true,
“index”: true,
“name”: “country_code”,
“store”: true,
“type”: “text”
}
]
},

I can get ancestors.country_code like this

{
“field”: “ancestors.country_code”,
“match”: “KR”
}

it works. what’s the difference between them?

Is the keyword analysed country_code an array field like earlier?

Keyword analyser wouldn’t apply any text analysis, rather keeps the input field content as it is.
So search for “KR” would work.

If you have any further queries, plz share the complete index definition and a sample document which you want to work on?