# Search DSL Query value with '(single quote) and space in elastic 6.8

**URL:** <https://discuss.elastic.co/t/search-dsl-query-value-with-single-quote-and-space-in-elastic-6-8/281091>\
**Category:** Elasticsearch\
**Created:** [August 11, 2021, 3:06pm UTC](https://discuss.elastic.co/t/search-dsl-query-value-with-single-quote-and-space-in-elastic-6-8/281091 "2021-08-11T15:06:02Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![joseph-l.amalraj](https://avatars.discourse-cdn.com/v4/letter/j/da6949/32.png) [@joseph-l.amalraj](https://discuss.elastic.co/u/joseph-l.amalraj)\
**Post date:** [August 11, 2021, 3:06pm UTC](https://discuss.elastic.co/t/search-dsl-query-value-with-single-quote-and-space-in-elastic-6-8/281091/1 "2021-08-11T15:06:02Z")

</div>

Hi, Actually, i am trying to do Search DSL Query value with '(single quote) like below query (1) and some times with single space Query (2) below, i am not getting expected results, Could you please suggest me for that. Because i have values in my content field. I am using elastic 6.8 version.  
Thank You.

(1)  
"match\_phrase": {  
"content": {  
"query": "Workers'"  
}  
}

(2)  
"match": {  
"content": {  
"query": "Workers "  
}  
}

---

<div class="post-metadata">

**Author:** ![monfera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/monfera/32/26467_2.png) [@monfera](https://discuss.elastic.co/u/monfera)\
**Post date:** [August 20, 2021, 3:31pm UTC](https://discuss.elastic.co/t/search-dsl-query-value-with-single-quote-and-space-in-elastic-6-8/281091/2 "2021-08-20T15:31:47Z")

</div>

Hello, this is an Elasticsearch question and it landed in the Kibana channel. How you can query heavily depends on your field mapping, eg. if the field was (also) created as a keyword, and if the entirety of the space separated text got in as one integral keyword rather than two keywords. This is a good starting point for [text vs keyword](https://www.elastic.co/blog/strings-are-dead-long-live-strings); again, worth delving into Elasticsearch itself and ask there if questions remain

There are also options with individual tokenization, with proximity search, where scoring depends on word proximity.

---

<div class="post-metadata">

**Author:** ![joseph-l.amalraj](https://avatars.discourse-cdn.com/v4/letter/j/da6949/32.png) [@joseph-l.amalraj](https://discuss.elastic.co/u/joseph-l.amalraj)\
**Post date:** [August 28, 2021, 2:00pm UTC](https://discuss.elastic.co/t/search-dsl-query-value-with-single-quote-and-space-in-elastic-6-8/281091/3 "2021-08-28T14:00:40Z")

</div>

Hi, To resolve above issue, I am trying to implement analyzer for my index, which needs to do search with special characters and white spaces. So, i am using n-gram analyzer.. Below my index..

Actually, my requirement to ingest pdf files(almost 2000 files), so, based on min and max-gram, it takes huge space and performance wise taking much time to get response for search.. Could you please suggest to improve performance and as well as if increase max-gram value to 100 or 200.  
Thank You in Advance.  
Joseph

PUT formslettersandtemplates4\_50  
{  
"settings": {  
"number\_of\_replicas" : "0",  
"refresh\_interval": null,  
"analysis": {  
"analyzer": {  
"form\_analyzer": {  
"tokenizer": "my\_tokenizer"  
}  
},  
"tokenizer": {  
"my\_tokenizer": {  
"type": "ngram",  
"min\_gram": 4,  
"max\_gram": 50,  
"token\_chars": [  
"letter",  
"digit",  
"whitespace",  
"punctuation",  
"symbol"  
]  
}  
}  
}  
},  
"mappings": {  
"doc" : {  
"properties": {  
"content": {  
"type": "text",  
"analyzer": "form\_analyzer"  
}  
}  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![monfera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/monfera/32/26467_2.png) [@monfera](https://discuss.elastic.co/u/monfera)\
**Post date:** [August 31, 2021, 8:27pm UTC](https://discuss.elastic.co/t/search-dsl-query-value-with-single-quote-and-space-in-elastic-6-8/281091/4 "2021-08-31T20:27:44Z")

</div>

Hi, it's really more of an Elasticsearch question and I'm not equipped to give performance advice on this. It might be worth considering a training course where there's room to ask questions about performance characteristics—besides this being taught on the courses—or some kind of consulting, or any kind of contract with support from our side. These besides the option of asking the question or browsing in the Elasticsearch discuss channel.

---

<div class="post-metadata">

**Author:** ![joseph-l.amalraj](https://avatars.discourse-cdn.com/v4/letter/j/da6949/32.png) [@joseph-l.amalraj](https://discuss.elastic.co/u/joseph-l.amalraj)\
**Post date:** [September 1, 2021, 1:15am UTC](https://discuss.elastic.co/t/search-dsl-query-value-with-single-quote-and-space-in-elastic-6-8/281091/5 "2021-09-01T01:15:47Z")

</div>

Sure Thank You Robert for your time.

I will refer that.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [September 7, 2021, 2:50pm UTC](https://discuss.elastic.co/t/search-dsl-query-value-with-single-quote-and-space-in-elastic-6-8/281091/6 "2021-09-07T14:50:25Z")

</div>

I moved the question to #elastic-stack:elasticsearch

Could you provide a full recreation script as described in [About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script is something anyone can **copy and paste in Kibana dev console** , click on the run button to reproduce your use case. It will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

---

<div class="post-metadata">

**Author:** ![joseph-l.amalraj](https://avatars.discourse-cdn.com/v4/letter/j/da6949/32.png) [@joseph-l.amalraj](https://discuss.elastic.co/u/joseph-l.amalraj)\
**Post date:** [September 7, 2021, 5:02pm UTC](https://discuss.elastic.co/t/search-dsl-query-value-with-single-quote-and-space-in-elastic-6-8/281091/7 "2021-09-07T17:02:10Z")

</div>

Thank You David. I am trying by below analyzer and tokenizer and i am able to get the expected result.

From this, tokenize for all special characters and white spaces with alpha characters happened properly.

PUT   
{  
"settings": {  
"analysis": {  
"analyzer": {  
"my\_analyzer": {  
"type": "custom",  
"tokenizer": "my\_tokenizer"  
}  
},  
"tokenizer" : {  
"my\_tokenizer": {  
"type":"char\_group",  
"tokenize\_on\_chars":[  
"whitespace", "symbol"]  
}  
}  
}  
},  
"mappings": {  
"doc": {  
"properties" : {  
"": {  
"type": "text",  
"analyzer": "my\_analyzer"  
}  
}  
}  
}  
}

---

<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:** [October 5, 2021, 5:02pm UTC](https://discuss.elastic.co/t/search-dsl-query-value-with-single-quote-and-space-in-elastic-6-8/281091/8 "2021-10-05T17:02:39Z")

</div>

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