Reputation: 888
I would like to seach using a wildcard serch term (eg "This i*") on the field "Description" which has a "lucene.keyword" analyzer defined using multi analyser. I have the following Index definition below
{
"mappings": {
"dynamic": false,
"fields": {
"Description": {
"analyzer": "lucene.standard",
"type": "string",
"multi": {
"keywordAnalyzer": {
"analyzer": "lucene.keyword",
"type": "string"
}
}
}
}
}
}
In my code i have the following..
var searchDefinition = Builders<T>.Search.Wildcard(
path:"Description",
query: "This i*",
allowAnalyzedField: true);
How do i specify to use the Multi Analyser option (keywordAnalyzer)? I see in the documentation to create it like below, but how do you do that using the MongoDriver when "Path" only take a string and not an object?
"text": {
"query": "driver",
"path": { "value": "description", "multi": "simpleAnalyzer" }
}
Upvotes: 0
Views: 26
Reputation: 888
The moment i posted the question i managed to resolve it using the following.
var def = new SearchPathDefinitionBuilder<T>().Analyzer("Desription", "keywordAnalyzer");
var searchDefinition = Builders<T>.Search.Wildcard(
path: def,
query: "This i*",
allowAnalyzedField: true);
Upvotes: 0