Unable to get results with keyword and custom analyzer


#1

I am not getting any results when I use keyword analyzer on the type mapping and custom single field analyzer on “content” field in travel-sample bucket.

My expectation is that when I use a keyword analyzer I would get results if my query matches exactly with any of the token streams

Version of Couchbase :: Enterprise Edition 6.0.0 build 1693 ‧ IPv4

Index definition ::

{
“name”: “travel-sample-index”,
“type”: “fulltext-index”,
“params”: {
“doc_config”: {
“docid_prefix_delim”: “”,
“docid_regexp”: “”,
“mode”: “type_field”,
“type_field”: “type”
},
“mapping”: {
“analysis”: {
“analyzers”: {
“custom_single_token_analyser”: {
“tokenizer”: “single”,
“type”: “custom”
}
}
},
“default_analyzer”: “keyword”,
“default_datetime_parser”: “dateTimeOptional”,
“default_field”: “_all”,
“default_mapping”: {
“dynamic”: true,
“enabled”: false
},
“default_type”: “_default”,
“docvalues_dynamic”: true,
“index_dynamic”: true,
“store_dynamic”: false,
“type_field”: “_type”,
“types”: {
“landmark”: {
“default_analyzer”: “keyword”,
“dynamic”: false,
“enabled”: true,
“properties”: {
“content”: {
“enabled”: true,
“dynamic”: false,
“fields”: [
{
“analyzer”: “custom_single_token_analyser”,
“include_in_all”: true,
“include_term_vectors”: true,
“index”: true,
“name”: “content”,
“store”: true,
“type”: “text”
}
]
}
}
}
}
},
“store”: {
“indexType”: “scorch”,
“kvStoreName”: “”
}
},
“sourceType”: “couchbase”,
“sourceName”: “travel-sample”,
“sourceUUID”: “b4bd996000c21b9f8bd555c7da6f3c39”,
“sourceParams”: {},
“planParams”: {
“maxPartitionsPerPIndex”: 171,
“numReplicas”: 0
},
“uuid”: “22e10abc46d34e07”
}

Query ::

curl -XPOST -H “Content-Type: application/json”
http://127.0.0.1:8094/api/index/travel-sample-index/query
-d ‘{
“explain”: true,
“fields”: [
“*”
],
“highlight”: {},
“query”: {
“query”: “light”
}
}’

Query Response ::

{
“status”: {
“total”: 6,
“failed”: 0,
“successful”: 6
},
“request”: {
“query”: {
“query”: “light”
},
“size”: 10,
“from”: 0,
“highlight”: {
“style”: null,
“fields”: null
},
“fields”: [
“*”
],
“facets”: null,
“explain”: true,
“sort”: [
“-_score”
],
“includeLocations”: false
},
“hits”: ,
“total_hits”: 0,
“max_score”: 0,
“took”: 0,
“facets”: null
}

Thanks for your support.


#2

I think there is a confusion here.
Keyword analyser is used when you want to index the field value as it is without any tokenisation/text analysis applied to it. Please read about analysers here: https://docs.couchbase.com/server/6.0/fts/fts-using-analyzers.html