I am using Elasticsearch 5.0.1, and I am running my code under .NET 4.5.2. I am using NEST 5.0 rc lib.
I have a class that contains a list of string.
public List<string> LastPagesViewed { get; set; }
I am mapping that clase using AutoMap like this:
.Mappings(m => m.Map<VisitorTest>(map => map.AutoMap()))
What I want to do is to query all the document that contains one or more urls on 'LastPagesViewed' property.
I am doing a search like this:
.Query(q => q
.Terms(c => c
.Name("named_query")
.Field(p => p.LastPagesViewed)
.Terms(new List<string> { "url1", "url2" }))
But it is not working. I also tried to search only part of the url like "google" (if the url is http://www.google.com ) but same result.
I tried this with a list of ints (instead of urls) and it is working, so what I am missing here?
Finally got it!. The problem was that I did not take into account the analyzer impact when using term search. Once I change the query to use a match it all works as expected.
The new query will be like this:
.Query(q => q.Match(mq => mq.Field(p => p.LastPagesViewed.First()).Query("http://www.google.com")))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.