# HELP with understanding of query

**URL:** <https://discuss.elastic.co/t/help-with-understanding-of-query/167429>\
**Category:** Elasticsearch\
**Created:** [February 7, 2019, 11:03am UTC](https://discuss.elastic.co/t/help-with-understanding-of-query/167429 "2019-02-07T11:03:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![DenEs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/denes/32/42250_2.png) [@DenEs](https://discuss.elastic.co/u/DenEs)\
**Post date:** [February 7, 2019, 11:03am UTC](https://discuss.elastic.co/t/help-with-understanding-of-query/167429/1 "2019-02-07T11:03:14Z")

</div>

Hello, can you help me understand, why simple query not working.  
I have a simple index with default settings:

```
PUT my_index/doc/1
{
  "path": "C:\\Windows\\system32\\cmd.exe"
}

```

Why the following query doesn't return anything?

```
GET my_index/_search
{
  "_source": "path", 
  "query": {
    "query_string": {
      "query": "(path: *\\system32\\*.exe)"
    }
  }
}
```

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [February 15, 2019, 7:45pm UTC](https://discuss.elastic.co/t/help-with-understanding-of-query/167429/2 "2019-02-15T19:45:40Z")

</div>

It's likely a mismatch with how the document was analyzed, and how the query is being analyzed. I would use the [Analyze API](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-analyze.html) to see how the document is tokenized. You can then see how the query is tokenized with the [Explain API](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-explain.html) and compare the two. Usually it becomes obvious how the two are analyzed differently and you can make corrections.

---

<div class="post-metadata">

**Author:** ![DenEs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/denes/32/42250_2.png) [@DenEs](https://discuss.elastic.co/u/DenEs)\
**Post date:** [February 20, 2019, 4:43pm UTC](https://discuss.elastic.co/t/help-with-understanding-of-query/167429/3 "2019-02-20T16:43:29Z")

</div>

I have checked analyzer and it gives standard output.

```
GET my_index/_analyze
{
  "text" : "C:\\Windows\\system32\\cmd.exe"
}

```

gives:

```
{
  "tokens": [
    {
      "token": "c",
      "start_offset": 0,
      "end_offset": 1,
      "type": "<ALPHANUM>",
      "position": 0
    },
    {
      "token": "windows",
      "start_offset": 3,
      "end_offset": 10,
      "type": "<ALPHANUM>",
      "position": 1
    },
    {
      "token": "system32",
      "start_offset": 11,
      "end_offset": 19,
      "type": "<ALPHANUM>",
      "position": 2
    },
    {
      "token": "cmd.exe",
      "start_offset": 20,
      "end_offset": 27,
      "type": "<ALPHANUM>",
      "position": 3
    }
  ]
}

```

Seems problem in escaping of star sign. "\_" should be "\\_"  
Following query works as expected:

```
GET my_index/_search
{
  "_source": "path", 
  "query": {
    "query_string": {
      "query": "(path.keyword: *\\system32\\\\*.exe)"
    }
  }
}
```

---

<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:** [March 20, 2019, 4:43pm UTC](https://discuss.elastic.co/t/help-with-understanding-of-query/167429/4 "2019-03-20T16:43:34Z")

</div>

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