Reputation: 4440
I am attempting to do a query in RavenDB using the Search
method, but I am running into an issue in that it completely ignores the KeywordAnalyzer
set up. So in a situation where I have ...
Trying to search for "Item 1" pulls up all three items, despite having set the analyzer on the name field to be the KeywordAnalyzer
, like this ...
Map = items => from item in items
select new Result {
Id = item.Id,
Name = item.Name
};
Index(i => i.Name, FieldIndexing.Analyzed);
Analyze(n => n.Name, "KeywordAnalyzer");
At which point, I use the index like this;
var results = RavenSession
.Query<Models.Items.Item, Indexes.Item__ByName>()
.Customize(c => c.WaitForNonStaleResults())
.Search(n => n.Name, name)
.ToList();
My expectations are that when I search for "Item 1", I only get back "Item 1
". Not all of the other items. But this just does not seem to be listening to me.
Upvotes: 1
Views: 332
Reputation: 4492
This is because you have 2 conflicting definitions:
Index(i => i.Name, FieldIndexing.Analyzed);
Analyze(n => n.Name, "KeywordAnalyzer");
The first tells it to use StandardAnalyzer, the second KeywordAnalyzer.
Remove the first line and you're set.
Upvotes: 4