# Getting unrelated data while searching with -\* in simple\_query\_string

**URL:** <https://discuss.elastic.co/t/getting-unrelated-data-while-searching-with-in-simple-query-string/336192>\
**Category:** Elasticsearch\
**Created:** [June 16, 2023, 6:15am UTC](https://discuss.elastic.co/t/getting-unrelated-data-while-searching-with-in-simple-query-string/336192 "2023-06-16T06:15:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ms.t](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@ms.t](https://discuss.elastic.co/u/ms.t)\
**Post date:** [June 16, 2023, 6:15am UTC](https://discuss.elastic.co/t/getting-unrelated-data-while-searching-with-in-simple-query-string/336192/1 "2023-06-16T06:15:52Z")

</div>

Hi  
I am using simple\_query\_string method with suffix \* (operator) for getting result  
But when i am searching with odd number of - getting unrelated data but with even number of - getting empty data.

 ![IMG-baa98f94336354e5b69aa88ae67c0877-V](https://us1.discourse-cdn.com/elastic/original/3X/b/2/b29131c8d8b98a0cf31bb22cc94aef00553b1cd2.jpeg)

---

<div class="post-metadata">

**Author:** ![RabBit\_BR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rabbit_br/32/82261_2.png) [@RabBit\_BR](https://discuss.elastic.co/u/RabBit_BR)\
**Post date:** [June 16, 2023, 7:05am UTC](https://discuss.elastic.co/t/getting-unrelated-data-while-searching-with-in-simple-query-string/336192/2 "2023-06-16T07:05:24Z")

</div>

Hi @ms.t

The use of images makes it difficult to reproduce the scenario, prefer to use code tools.

If possible, provide data such as mapping and documents so that it is possible to reproduce the problem.

---

<div class="post-metadata">

**Author:** ![ms.t](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@ms.t](https://discuss.elastic.co/u/ms.t)\
**Post date:** [June 16, 2023, 8:20am UTC](https://discuss.elastic.co/t/getting-unrelated-data-while-searching-with-in-simple-query-string/336192/3 "2023-06-16T08:20:30Z")

</div>

Hi @RabBit_BR, index mapping and sample document for your reference

{"mappings":{"properties":{"application":{"type":"keyword"},"creationTime":{"type":"date"},"description":{"type":"text"},"entityCreatedOn":{"type":"date"},"entityModifiedOn":{"type":"date"},"entityUniqueId":{"type":"keyword"},"modificationTime":{"type":"date"},"protectedRecord":{"type":"boolean"},"queryText":{"type":"object"},"metaData":{"type":"text"},"searchAppearance":{"type":"object"},"visitCount":{"type":"long"},"roleRelated":{"type":"keyword"},"title":{"type":"text"},"type":{"type":"keyword"},"url":{"type":"keyword"},"userRelated":{"type":"keyword"},"workGroupRelated":{"type":"keyword"}}},"settings": {  
"analysis": {  
"analyzer": {  
"default": {  
"tokenizer": "whitespace",  
"filter": ["lowercase","my\_custom\_stop\_words\_filter"]  
}  
},  
"filter": {  
"my\_custom\_stop\_words\_filter": {  
"type": "stop",  
"ignore\_case": true,  
"stopwords": ["and", "is", "the", "a", "an", "are", "as", "at", "be", "but", "by", "for", "if", "in", "into", "it", "no", "not", "of", "on", "or", "such", "that", "their", "then", "there", "these", "they", "this", "to", "was", "will", "with","am"]  
}  
}  
}  
}}

Document :

{  
"entityUniqueId": "searchAppearanceTest2",  
"application": "Administration",  
"type": "User",  
"title": "test data",  
"description": "For search testing purpose",  
"url": "",  
"queryText": null,

"metaData": null,  
"userRelated": ["manohar.singh"],  
"workGroupRelated": null,  
"protectedRecord": false,  
"entityCreatedOn": 1645091657260,  
"entityModifiedOn": 1645091657260  
}

---

<div class="post-metadata">

**Author:** ![RabBit\_BR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rabbit_br/32/82261_2.png) [@RabBit\_BR](https://discuss.elastic.co/u/RabBit_BR)\
**Post date:** [June 16, 2023, 2:14pm UTC](https://discuss.elastic.co/t/getting-unrelated-data-while-searching-with-in-simple-query-string/336192/4 "2023-06-16T14:14:33Z")

</div>

Hi @ms.t

You are using a operator. Look the [doc](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-simple-query-string-query.html#simple-query-string-syntax):

the `simple_query_string` query supports the following operators:

> - `+` signifies AND operation
> - `|` signifies OR operation
> - `-` negates a single token
> - `"` wraps a number of tokens to signify a phrase for searching
> - `*` at the end of a term signifies a prefix query
> - `(` and `)` signify precedence
> - `~N` after a word signifies edit distance (fuzziness)
> - `~N` after a phrase signifies slop amount

---

<div class="post-metadata">

**Author:** ![ms.t](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@ms.t](https://discuss.elastic.co/u/ms.t)\
**Post date:** [June 19, 2023, 8:10am UTC](https://discuss.elastic.co/t/getting-unrelated-data-while-searching-with-in-simple-query-string/336192/5 "2023-06-19T08:10:50Z")

</div>

Hi @RabBit_BR ,  
Could you please explain why i am getting unrelated data when using odd number of - with suffix \* with sample\_query\_string method?

---

<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 17, 2023, 8:10am UTC](https://discuss.elastic.co/t/getting-unrelated-data-while-searching-with-in-simple-query-string/336192/6 "2023-07-17T08:10:56Z")

</div>

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