Hello everyone,
I’m new with atlas search and I don’t know how I can build an ‘OR’ operator through multiple fields.
Here is what I did:
Search index configuration:
{
"searchAnalyzer": "lucene.keyword",
"mappings": {
"dynamic": false,
"fields": {
"lrn": {
"analyzer": "lucene.keyword",
"type": "string"
},
"title": {
"analyzer": "aks_ngram",
"type": "string"
}
}
},
"analyzers": [
{
"charFilters": [],
"name": "aks_ngram",
"tokenFilters": [
{
"type": "lowercase"
}
],
"tokenizer": {
"maxGram": 10,
"minGram": 2,
"type": "nGram"
}
}
]
}
My search query:
{
$search: {
index: "default",
compound: {
should: [
{
text: {
query: "558988b6b1661680917206",
path: "title",
}
},
{
text: {
query: "558988b6b1661680917206",
path: "lrn"
}
}
]
}
}
}
What do I expect to get:
[
{
title: 'WXYZQP',
lrn: '558988b6b1661680917206'
}
]
What do I get:
[
{
title: '75669860766',
lrn: '5832748721661680917174'
},
{
title: 'WXYZQP',
lrn: '558988b6b1661680917206'
}
]
I want on the “title” field to search only by substrings and “lrn” to be perfect match.
Thanks!