# Straight vs. Curly Quotes Affecting Search

**URL:** <https://discuss.elastic.co/t/straight-vs-curly-quotes-affecting-search/92911>\
**Category:** Kibana\
**Created:** [July 13, 2017, 3:23am UTC](https://discuss.elastic.co/t/straight-vs-curly-quotes-affecting-search/92911 "2017-07-13T03:23:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jacqueline\_Kong](https://avatars.discourse-cdn.com/v4/letter/j/8dc957/32.png) [@Jacqueline\_Kong](https://discuss.elastic.co/u/Jacqueline_Kong)\
**Post date:** [July 13, 2017, 3:23am UTC](https://discuss.elastic.co/t/straight-vs-curly-quotes-affecting-search/92911/1 "2017-07-13T03:23:01Z")

</div>

Hello! I have noticed that when I enter search parameters in a visualisation or in the Discovery pane in Kibana, the quotation marks being straight vs. curly affect whether or not the search is valid. However, it seems inconsistent as to which is valid; sometimes the straight quotation marks work and sometimes the curly ones work.

Why does the quotation mark style affect the search? I have had to go back to my visualisations and redo all the searches multiple times to change the quotation mark style. Is there something I can change so that both types of quotation marks are valid?

---

<div class="post-metadata">

**Author:** ![Bargs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bargs/32/5429_2.png) [@Bargs](https://discuss.elastic.co/u/Bargs)\
**Post date:** [July 13, 2017, 2:37pm UTC](https://discuss.elastic.co/t/straight-vs-curly-quotes-affecting-search/92911/2 "2017-07-13T14:37:26Z")

</div>

Could you provide some examples of queries that fail?

---

<div class="post-metadata">

**Author:** ![Jacqueline\_Kong](https://avatars.discourse-cdn.com/v4/letter/j/8dc957/32.png) [@Jacqueline\_Kong](https://discuss.elastic.co/u/Jacqueline_Kong)\
**Post date:** [July 14, 2017, 1:30am UTC](https://discuss.elastic.co/t/straight-vs-curly-quotes-affecting-search/92911/3 "2017-07-14T01:30:46Z")

</div>

Hi Matt,

Here are some examples from our data:

data.status=“Active” and data.status="Active" are both okay.

\_type:“personal” fails whereas \_type:"personal" returns documents  
\_index:“event” vs. \_index:"event" similarly

Both types of quotes seem to work for our custom fields, but curly quotes (ASCII value 8220 and 8221) fail when used with Elasticsearch's default fields, such as \_type and \_index.

---

<div class="post-metadata">

**Author:** ![Bargs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bargs/32/5429_2.png) [@Bargs](https://discuss.elastic.co/u/Bargs)\
**Post date:** [July 14, 2017, 2:13pm UTC](https://discuss.elastic.co/t/straight-vs-curly-quotes-affecting-search/92911/4 "2017-07-14T14:13:46Z")

</div>

Thanks for the additional info. Here's what I think it happening.

The curly quotes never work as expected but that fact is being hidden. Straight double quotes have a special meaning in the [Query String query](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#query-string-syntax), they indicate a phrase search. So any text wrapped in straight double quotes (including whitespace) will be sent as a single term. Curly quotes are not special and are not recognized by the Query String query. They are treated as regular text.

So when you search for `data.status=“Active”` you're literally searching for the text `“Active”` (including the curly double quotes). When you search for `data.status="Active"` you're only searching for `Active` (no quotes) because straight double quotes are special characters in the query language.

Here's the tricky bit: I bet the mapping for `data.status` uses an analyzer (or uses the default analyzer) which strips characters like `“”`, so after analysis you're only searching for `Active` which is identical to our straight double quote query.

You can test this via the `_analyze` API:

```auto
GET <index-name>/_analyze 
{
  "field": "data.status", 
  "text": "“Active”"
}

```

The response will most likely look like this:

```auto
{
  "tokens": [
    {
      "token": "active",
      "start_offset": 1,
      "end_offset": 7,
      "type": "<ALPHANUM>",
      "position": 0
    }
  ]
}

```

Curly double quotes don't appear to work with most of the Elasticsearch metafields because they are not analyzed, hence the quotes don't get stripped and the search term does not match.

Another way to see this is to search for a value with a space in it. Try `data.status=“foo bar”` vs `data.status="foo bar"`. In the first example you're actually searching for two separate terms. `data.status=“foo` AND `bar”`. In the second example you're searching for a single phrase, `foo bar`.

---

<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:** [August 11, 2017, 2:14pm UTC](https://discuss.elastic.co/t/straight-vs-curly-quotes-affecting-search/92911/5 "2017-08-11T14:14:03Z")

</div>

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