Using must finds document, using should doesn't - why?

Hi all,

I am having trouble using must vs. should delivering strange results...

Searching for the phrase "123 Dummy 01/10"

When using must (or should) with only this one Phrase:

[query] => Array(
  [bool] => Array(
    [must] => Array(
      [0] => Array(
        [match_phrase] => Array(
          [_full_text] => 123 Dummy 01/10
        )
      )
    )
  )
)

the result is one document, which is correct: there is exactly one document in the index with this phrase.

Now...
When using should with "123 Dummy 01/10" and "123 Dummy 1/10"

[query] => Array(
  [bool] => Array(
    [should] => Array(
      [0] => Array(
        [match_phrase] => Array(
          [_full_text] => 123 Dummy 1/10
        )
      )
      [1] => Array (
        [match_phrase] => Array (
          [_full_text] => 123 Dummy 01/10
        )
      )
    )
    [minimum_should_match] => 1
  )
)

the result is no document at all...

I have not yet found anything on why this happens or how I can get it to work :frowning:

Maybe someone can help me in my struggle?

i tested the same querys with my local data and it works (with default analyzer) you had the json query that you send to Elasticsearch? try to get your json and test in Elasticsearch with marvel sense, or the plugin head! it can be a problem with double slash, corrupted array...
my test query :

{
  "query": {
    "bool": {
      "should": [
        {
          "match_phrase": {
            "os_version": "firefox 6"
          }
        },
        {
          "match_phrase": {
            "os_version": "firefox 06"
          }
        }
      ],
      "minimum_number_should_match": 1
    }
  }
}

Hi Camilo,

trying at the command prompt using JSON it worked :frowning:

We are using the PHP-Client and after some further testing I found that obviously (like you stated) the slash in 01/10 could really be the problem.

When searching

[query] => Array(
  [bool] => Array(
    [should] => Array(
      [0] => Array(
        [match_phrase] => Array(
          [_full_text] => 123 Dummy 1
        )
      )
      [1] => Array (
        [match_phrase] => Array (
          [_full_text] => 123 Dummy 01
        )
      )
    )
    [minimum_should_match] => 1
  )
)

the result will deliver the correct document.

Do you (or anybody else) know a solution to this other than not using the PHP-Client?