ElasticSearch / NEST / No results with "Term" but with "Match"

Arne Nöhre

Why does the first statement give me some results but the second not?

I tried a lot of combinations, but I don't get any idea what the problem might be. Of course the "Term"-Approach would be my preferred one.

 var matchPhrase = _client.Search<JournalItem>(s => s
            .Index("journal")
            .Query(q => q.Match(m => m.OnField("typeName")
                 .Query("Logon"))));


var searchResults = _client.Search<JournalItem>(s => s
            .Index("journal")
            .Query(q => q
                .Term(p => p.typeName, "Logon")
            ));

I am using NEST 1.4 with elasticsearch 1.4.2

Dan Tuffery

The term query does not analyze the search term, the match query uses the same analyzer for search as was used to index the field. So if you used the default analyzer (Standard analyzer) to index p.typeName, the indexed term is 'logon' (the Standard analyzer splits on white case and lower cases the term), as your search term 'Logon' has mixed case it will not match with the Term query.

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-term-query.html

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Related Related

HotTag

Archive