# Only Exact Search Matches for Quoted Phrases

**URL:** https://discuss.elastic.co/t/only-exact-search-matches-for-quoted-phrases/176698
**Category:** Elastic Search
**Tags:** elastic-site-search
**Created:** [April 12, 2019, 7:35pm UTC](https://discuss.elastic.co/t/only-exact-search-matches-for-quoted-phrases/176698 "2019-04-12T19:35:05Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![timlwhite](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timlwhite/32/43690_2.png) [@timlwhite](https://discuss.elastic.co/u/timlwhite)
#### Post date: [April 12, 2019, 7:35pm UTC](https://discuss.elastic.co/t/only-exact-search-matches-for-quoted-phrases/176698/1 "2019-04-12T19:35:06Z")

</div>

Hello -

I need to enable searches that return only exact matches for quoted phrases.

For example "Bank of America" should not return results that only contain "America" or "bank" as these are common words in the search corpus.

I have tried using escaped quotations, "Bank of America" as well as other various versions of quoting strings, and I continue to get non-exact matches.

Google does this quite well, I am trying to determine how to coerce SwiftType to do the same.

Thank you!

---

<div class="post-metadata">

### Author: ![goodroot](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/goodroot/32/38389_2.png) [@goodroot](https://discuss.elastic.co/u/goodroot)
#### Post date: [April 12, 2019, 8:04pm UTC](https://discuss.elastic.co/t/only-exact-search-matches-for-quoted-phrases/176698/2 "2019-04-12T20:04:11Z")

</div>

Hey Tim ~

Thanks for joining the community. 🎉

I've tested this locally within a demo Engine. Here's what I see...

A query without quotes, with `highlight_fields`:

```auto
 curl -XGET 'https://search-api.swiftype.com/api/v1/public/engines/search.json' \
  -H 'Content-Type: application/json' \
  -d '{
        "engine_key": "swiftype-api-example",
        "q": "Grumpy Cat",
        "highlight_fields":{
          "videos":{"title":{"size":60,"fallback":false}}
        }
      }' | jq

```

Result 1:

```json
...
"title": "<em>Grumpy</em> <em>Cat</em> Does The Harlem Shake (Ad Free)"
...

```

Result 2:

```auto
...
"title": "Nyan <em>Cat</em> [original]"
...

```

I see partial matches -- but that's what we'd expect.

The same query _with_ quotes:

```auto
curl -XGET 'https://search-api.swiftype.com/api/v1/public/engines/search.json' -H 'Content-Type: application/json' -d '{
        "engine_key": "swiftype-api-example",
        "q": "\"Grumpy Cat\"",
        "highlight_fields":{
          "videos":{"title":{"size":60,"fallback":false}}
        }
      }' | jq

```

Result 1:

```json
...
"title": "<em>Grumpy</em> <em>Cat</em> Does The Harlem Shake (Ad Free)"
...

```

I receive only one result as expected -- the exact match. It's highlighted whole.

It might be the escaping method. Perhaps you can share some similar queries, and we can get to the bottom of things.

Happy Friday,

Kellen

---

<div class="post-metadata">

### Author: ![timlwhite](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timlwhite/32/43690_2.png) [@timlwhite](https://discuss.elastic.co/u/timlwhite)
#### Post date: [April 15, 2019, 2:47pm UTC](https://discuss.elastic.co/t/only-exact-search-matches-for-quoted-phrases/176698/3 "2019-04-15T14:47:18Z")

</div>

Thank you! I think part of the challenge is that in the "Search Preview" in the Swiftype console, I have to enter those escaped quotes as well, which seems like a UI bug.

Also, checking my corpus, I still get results that aren't an exact match, they just have nothing highlighted. But I do get significantly fewer using escaped quotes, but it's not none. There are just too many articles that have "bank" and "America" in them. ☹

---

<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: [May 13, 2019, 2:47pm UTC](https://discuss.elastic.co/t/only-exact-search-matches-for-quoted-phrases/176698/4 "2019-05-13T14:47:20Z")

</div>

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