0

Elasticsearch when queried with the following returns no results.

{  
  "query":{  
    "filtered":{  
      "query":{  
        "bool":{  
          "should":[  
            {  
              "query_string":{  
                "query":"a*",
                "analyze_wildcard":true
              }
            }
          ]
        }
      }
    }
  }
}

When I use "al*" instead of "a*", I am getting proper results. This is happening for "a*" only. When I use any others like "b*" or "c*", etc. the results are proper

I am using elasticsearch version 0.90.12

1 Answer 1

1

This is because a is a stop word and gets eliminated by the standard analyzer that analyzes your query. You can probably get around this by specifying a different analyzer, such as keyword instead of using the standard one. Another option is to leave analyze_wildcard set to false.

{  
  "query":{  
    "filtered":{  
      "query":{  
        "bool":{  
          "should":[  
            {  
              "query_string":{  
                "query":"a*",
                "analyze_wildcard":true,
                "analyzer": "keyword"
              }
            }
          ]
        }
      }
    }
  }
}
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for you reply. Can you please explain how "a.*" in the query above searches for. I have a record "A. J. Satya" and it is not getting returned when searched using "a.*" in the above query.
The problem is that at indexing time the value A. J. Satya will get tokenized as the tokens j and satya because a is an english stop word and gets discarded. You probably need to change the analyzer you're using at indexing time too.
Thanks for the explanation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.