Prefix query with whitespaces

Hi.

Why does the following prefix query return zero results:

{
  "prefix": {
    "some_field": {
      "value": "hello wor"
    }
  }
}

Whereas the simple_query_string seems do what I want (and return the relevant results):

{
  "simple_query_string": {
    "fields": ["some_field"],
    "default_operator": "and",
    "query": "(hello wor*)"
  }
}

Because the query is user-given, I'd really need to use the prefix-query, but it's not working the way I expected. Any tips, why that is?

OK, so the issue seems to be that prefix is term-level query. That's why the whitespace doesn't work there.

Now, I guess the alternative would be to use the Match Phrase Prefix -query, but that requires fiddling with the max_expansions -parameter.

Isn't there a simple alternative to simple_query_string that could be used easily without worrying escaping user input?

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