Contains query on text field with keyword analyzer breaking at whitespace


I need to perform in query on the field with "keyword" analyzer.

An exact search is successful and return correct result but contains query always fail. I also needed the keyword to search with lower case so I tried this and it is working .. here is the code

        'var descriptor = new CreateIndexDescriptor("myindex")
               .Settings(s => s
                    .Analysis(a => a
                        .Analyzers(an => an
                            .Custom("case_insensitive", ca => ca
            .Mappings(ms => ms
                             .Map<Employee>("employee", m => m.AutoMap().Properties(p => p
                                  .Text(t => t.Name(n => n.Name).Analyzer("case_insensitive").Fielddata(true))                                      
        var response = ESContext.CreateIndex(descriptor);'

Above created this mapping

"name": {
"type": "text",
"analyzer": "case_insensitive",
"fielddata": true

Now when I have these names =>
1. Namrata Mathur
2. Namrata
3. Namrata Rai

If I apply contains search and look for "Namrata Mathur" I am only getting 2nd row "Namrata" .. and when I type a whitespace I am getting all three rows.

Here it the query which ElasticLinq generating:

"query":{"bool":{"must":[{"term":{"archive":false}},{"query_string":{"query":"Namrata Mathur*","fields":["name"]}},{"term":{"companyId":4}}]}},"size":100,"timeout":"10s"}

Please help me, what should I do now .. why my search breaks at whitespace .. please guide.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.