# Query & filter return no result

**URL:** <https://discuss.elastic.co/t/query-filter-return-no-result/26982>\
**Category:** Elasticsearch\
**Created:** [August 6, 2015, 3:28pm UTC](https://discuss.elastic.co/t/query-filter-return-no-result/26982 "2015-08-06T15:28:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Frederic\_Laurent](https://avatars.discourse-cdn.com/v4/letter/f/c67d28/32.png) [@Frederic\_Laurent](https://discuss.elastic.co/u/Frederic_Laurent)\
**Post date:** [August 6, 2015, 3:28pm UTC](https://discuss.elastic.co/t/query-filter-return-no-result/26982/1 "2015-08-06T15:28:12Z")

</div>

Hello all,

I'm trying to make requests (very simples) on a very small dataset : 4 documents available here  
[https://gist.github.com/flrt/a9f29c838bfa06a2faa5#file-create-es-units-testplan-sh](https://gist.github.com/flrt/a9f29c838bfa06a2faa5#file-create-es-units-testplan-sh)

What I want (for the beginning) :

- unclosed units with title or name contains CARDIO

The idea is

- to filter the unclosed units
- query the fields in order to have a score (otherwise by default a filter can be used)

The mapping is the following

```
curl -XGET http://localhost:9200/units/_mapping
{
    "units":
    {
        "mappings":
        {
            "unit":
            {
                "properties":
                {
                    "closed":
                    {
                        "type": "date",
                        "format": "dateOptionalTime"
                    },
                    "code":
                    {
                        "type": "string"
                    },
                    "title":
                    {
                        "type": "string"
                    },
                    "user":
                    {
                        "properties":
                        {
                            "name":
                            {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        }
    }
}

```

My (broken) tests

Test 1/ Trying to follow [https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-filter.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-filter.html)

I added the "query" key in the first place. Without, like in the docs, when I'm starting the json with filetered, I have the following exception

```
SearchParseException[[units][4]: from[-1],size[-1]: Parse Failure [No parser for element [filtered]]]; }]",

curl -XGET http://localhost:9200/units/unit/_search -d'{
  "query": {
    "filtered": {
      "query": {
        "query_string": {
          "query": "CARDIO"
        }
      },
      "filter": {
        "bool": {
          "must_not": {
            "exists": {
              "field": "closed"
            }
          }
        }
      }
    }
  }
}'

```

**--\> 0 results**

Test 2/ Trying to follow [https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-filtered-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-filtered-query.html)

```
curl -XGET http://localhost:9200/units/unit/_search -d'{
  "query": {
    "filtered": {
      "query": {
        "match": {
          "title": "CARDIO"
        }
      },
      "filter": {
        "bool": {
          "must_not": {
            "exists": {
              "field": "closed"
            }
          }
        }
      }
    }
  }
}'

```

**--\> 0 results**

Test 3/ Trying to follow [https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html)

```
curl -XGET http://localhost:9200/units/unit/_search -d'{
  "multi_match": {
    "query": "CARDIO",
    "fields": [
      "title^2",
      "user.name"
    ]
  }
}

```

--\> Execption SearchParseException[[units](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html): from[-1],size[-1]: Parse Failure [No parser for element [multi\_match]]]; }]

Test 4 / trying to mix multi\_match and filter

```
curl -XGET http://localhost:9200/units/unit/_search -d'{
  "query": {
    "filtered": {
      "query": {
        "multi_match": {
          "query": "CARDIO",
          "fields": [
            "title^2",
            "user.name"
          ]
        }
      },
      "filter": {
        "bool": {
          "must_not": {
            "exists": {
              "field": "closed"
            }
          }
        }
      }
    }
  }
}

```

**--\> 0 results**

But I have got a good result when I'm searching the unclosed units

```
curl -XGET http://localhost:9200/units/unit/_search -d'{
  "query": {
    "filtered": {
      "filter": {
        "bool": {
          "must_not": {
            "exists": {
              "field": "closed"
            }
          }
        }
      }
    }
  }
}

```

**--\> 3 results**

I tried to put CARDIO and CARDIO\*, but it's the same result.  
I think these tests are very simples and I can't figure out why they fails.

Any idea ?

---

<div class="post-metadata">

**Author:** ![Frederic\_Laurent](https://avatars.discourse-cdn.com/v4/letter/f/c67d28/32.png) [@Frederic\_Laurent](https://discuss.elastic.co/u/Frederic_Laurent)\
**Post date:** [August 7, 2015, 7:38am UTC](https://discuss.elastic.co/t/query-filter-return-no-result/26982/2 "2015-08-07T07:38:57Z")

</div>

Hello

In fact, I would like to produce the intersection between

- [http://localhost:9200/units/unit/\_search?q=](http://localhost:9200/units/unit/_search?q=)_missing_:closed
- [http://localhost:9200/units/unit/\_search?q=CARDIO\*](http://localhost:9200/units/unit/_search?q=CARDIO*)

The first one gives 3 results, and the second one gives 2. Only one is in common.

But I can't set these 2 conditions in the query string when using the URI search, and the json expression does not return anything, as explained at the beginning of these post.

Thanks in advance

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:56pm UTC](https://discuss.elastic.co/t/query-filter-return-no-result/26982/3 "2017-07-05T23:56:54Z")

</div>


