Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistency in multi_match query #16098

Closed
bittusarkar opened this issue Jan 19, 2016 · 8 comments
Closed

Inconsistency in multi_match query #16098

bittusarkar opened this issue Jan 19, 2016 · 8 comments
Labels
>bug good first issue low hanging fruit help wanted adoptme :Search/Search Search-related issues that do not fall into other categories

Comments

@bittusarkar
Copy link

There is a discrepancy in the behaviour of multi_match query when it comes to resolving field names containing wildcard characters.

The following query will return zero results if the field subject does not exists.

{
  "multi_match" : {
    "query":    "this is a test", 
    "fields": [ "subject" ] 
  }
}

But the following query will fail with an exception saying "No fields specified for multi_match query" if there is no field whose name starts with "ms" in the index being queried. Ideally it should return zero results too instead of failing right?

{
  "multi_match" : {
    "query":    "this is a test", 
    "fields": [ "ms*" ] 
  }
}

I have a use case where fields are dynamically added to the mapping and users can provide the field name to match search text on. Fields added to the mapping also have a metadata string appended to their names which the user may not be aware about. Hence I need to use wildcards in the field name in a multi_match query and there are chances that no field name matches too.

@clintongormley
Copy link

I agree. Related to #12016

@michel-kraemer
Copy link

I bumped into this too. Is there a workaround that I can apply until this issue has been solved?

@0xbok
Copy link

0xbok commented Mar 4, 2016

Is this fixed now?
I just pulled the code from master and the second query is returning zero results (I ensured that there is no field starting with 'ms').

michel-kraemer added a commit to georocket/georocket that referenced this issue May 6, 2016
@qwerty4030
Copy link
Contributor

@clintongormley Confirmed this is not reproducible on latest master with the following:

POST test-index/test-type/test-doc1
{
  "test-key":"test-value"
}

POST test-index/_search
{
  "query": {
    "multi_match": {
      "query": "test-query",
      "fields": [
        "doesnt-match*"
      ]
    }
  }
}
results in 0 hits

However the same query fails on 2.3.2. Which release will the changes from #12016 land in?

@clintongormley
Copy link

This is fixed in master thanks to a massive refactoring of how searches are parsed - this obviously can't be backported. If somebody wants to contribute a quick fix for 2.4, then please submit a PR.

@andrewla
Copy link

andrewla commented Nov 4, 2016

One workaround this that I've found is to add a dummy field to the fields specification, like "fields": ["dummydummydummy", "ms*"], which will trigger the behavior on missing fields without causing the wildcard misfiring. Not sure if this makes the query significantly more expensive.

michel-kraemer added a commit to georocket/georocket that referenced this issue Nov 7, 2016
@michel-kraemer
Copy link

This issue seems to be fixed in 5.0.0. As far as I am concerned it can be closed.

@clintongormley
Copy link

Fixed in 5.0, closing

@clintongormley clintongormley added :Search/Search Search-related issues that do not fall into other categories and removed :Query DSL labels Feb 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug good first issue low hanging fruit help wanted adoptme :Search/Search Search-related issues that do not fall into other categories
Projects
None yet
Development

No branches or pull requests

6 participants