# How to implement proximity search in app search

**URL:** https://discuss.elastic.co/t/how-to-implement-proximity-search-in-app-search/203966
**Category:** Elastic Search
**Tags:** elastic-app-search
**Created:** [October 17, 2019, 4:31am UTC](https://discuss.elastic.co/t/how-to-implement-proximity-search-in-app-search/203966 "2019-10-17T04:31:45Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![ranjeet.tiwari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ranjeet.tiwari/32/55160_2.png) [@ranjeet.tiwari](https://discuss.elastic.co/u/ranjeet.tiwari)
#### Post date: [October 17, 2019, 4:31am UTC](https://discuss.elastic.co/t/how-to-implement-proximity-search-in-app-search/203966/1 "2019-10-17T04:31:46Z")

</div>

How to implement proximity search in app search?

---

<div class="post-metadata">

### Author: ![ranjeet.tiwari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ranjeet.tiwari/32/55160_2.png) [@ranjeet.tiwari](https://discuss.elastic.co/u/ranjeet.tiwari)
#### Post date: [October 22, 2019, 6:52am UTC](https://discuss.elastic.co/t/how-to-implement-proximity-search-in-app-search/203966/2 "2019-10-22T06:52:18Z")

</div>

@JasonStoltz, please help

---

<div class="post-metadata">

### Author: ![JasonStoltz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasonstoltz/32/49893_2.png) [@JasonStoltz](https://discuss.elastic.co/u/JasonStoltz)
#### Post date: [October 22, 2019, 11:36am UTC](https://discuss.elastic.co/t/how-to-implement-proximity-search-in-app-search/203966/3 "2019-10-22T11:36:04Z")

</div>

Hi @ranjeet.tiwari,

Sorry for the late reply, I have been out for a few days.

You should be able to filter a query by proximity using a geo filter. The documentation for that is here: [https://swiftype.com/documentation/app-search/api/search/filters#geo-filters](https://swiftype.com/documentation/app-search/api/search/filters#geo-filters).

---

<div class="post-metadata">

### Author: ![JasonStoltz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasonstoltz/32/49893_2.png) [@JasonStoltz](https://discuss.elastic.co/u/JasonStoltz)
#### Post date: [October 22, 2019, 11:40am UTC](https://discuss.elastic.co/t/how-to-implement-proximity-search-in-app-search/203966/4 "2019-10-22T11:40:54Z")

</div>

You can also boost the relevance score of document based on a proximity. [https://swiftype.com/documentation/app-search/api/search/boosts#proximity-boosts](https://swiftype.com/documentation/app-search/api/search/boosts#proximity-boosts)

---

<div class="post-metadata">

### Author: ![ranjeet.tiwari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ranjeet.tiwari/32/55160_2.png) [@ranjeet.tiwari](https://discuss.elastic.co/u/ranjeet.tiwari)
#### Post date: [October 28, 2019, 8:40am UTC](https://discuss.elastic.co/t/how-to-implement-proximity-search-in-app-search/203966/5 "2019-10-28T08:40:16Z")

</div>

@JasonStoltz  
its only for **number** and **geolocation** fields.

We want to apply the proximity search on text field and we want to achieve the proximity search functionality which should very similar to elasticsearch.

Please have look at below reference

> **[Proximity matching in Elasticsearch](https://www.waitingforcode.com/elasticsearch/proximity-matching-in-elasticsearch/read)**
>
> Elasticsearch and its idea of inverted index is a kind of magic infinitely deep hat in which we can hide millions of terms. However, sometimes these terms need to be analyzed with some logic, not just only as plain words. It's here where proximity...

---

<div class="post-metadata">

### Author: ![JasonStoltz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasonstoltz/32/49893_2.png) [@JasonStoltz](https://discuss.elastic.co/u/JasonStoltz)
#### Post date: [October 28, 2019, 10:28am UTC](https://discuss.elastic.co/t/how-to-implement-proximity-search-in-app-search/203966/6 "2019-10-28T10:28:15Z")

</div>

@ranjeet.tiwari I'm fairly certain that is not possible with App Search, unfortunately.

---

<div class="post-metadata">

### Author: ![ranjeet.tiwari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ranjeet.tiwari/32/55160_2.png) [@ranjeet.tiwari](https://discuss.elastic.co/u/ranjeet.tiwari)
#### Post date: [October 28, 2019, 10:30am UTC](https://discuss.elastic.co/t/how-to-implement-proximity-search-in-app-search/203966/7 "2019-10-28T10:30:38Z")

</div>

Thanks @JasonStoltz.....

One more thing....

Can we change the engine name and refresh the result in search ui….  
Actually I have 2 tabs in search page...based on selection of tab, I am trying to refresh the result.  
Is this possible?

---

<div class="post-metadata">

### Author: ![JasonStoltz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasonstoltz/32/49893_2.png) [@JasonStoltz](https://discuss.elastic.co/u/JasonStoltz)
#### Post date: [October 28, 2019, 10:32am UTC](https://discuss.elastic.co/t/how-to-implement-proximity-search-in-app-search/203966/8 "2019-10-28T10:32:10Z")

</div>

Yes, that should be possible. Can you elaborate?

---

<div class="post-metadata">

### Author: ![JasonStoltz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasonstoltz/32/49893_2.png) [@JasonStoltz](https://discuss.elastic.co/u/JasonStoltz)
#### Post date: [October 28, 2019, 10:36am UTC](https://discuss.elastic.co/t/how-to-implement-proximity-search-in-app-search/203966/9 "2019-10-28T10:36:45Z")

</div>

Like do you have one search box and you'd like to show results from different engines in two different tabs?

---

<div class="post-metadata">

### Author: ![ranjeet.tiwari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ranjeet.tiwari/32/55160_2.png) [@ranjeet.tiwari](https://discuss.elastic.co/u/ranjeet.tiwari)
#### Post date: [October 28, 2019, 10:37am UTC](https://discuss.elastic.co/t/how-to-implement-proximity-search-in-app-search/203966/10 "2019-10-28T10:37:07Z")

</div>

yes.... @JasonStoltz  
Please have a look  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/9/9/997fe0ba9c762bf9fcae56dfb81bce0827f69e8d.png)

---

<div class="post-metadata">

### Author: ![JasonStoltz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasonstoltz/32/49893_2.png) [@JasonStoltz](https://discuss.elastic.co/u/JasonStoltz)
#### Post date: [October 28, 2019, 11:12am UTC](https://discuss.elastic.co/t/how-to-implement-proximity-search-in-app-search/203966/11 "2019-10-28T11:12:21Z")

</div>

@ranjeet.tiwari It would be neat to have a better way to support this, but I'd recommend trying something like the following. Keep in mind that this is just pseudo-code to illustrate the concept I have in mind:

```auto
state = {
  engine: 'engine1'
}

const connector = new AppSearchAPIConnector({
  searchKey: "",
  engineName: this.state.engineName,
  hostIdentifier: ""
});

return <SearchProvider
  config={{
    apiConnector: connector
  }}
>
  <div>
    <SearchBox />
    <Tab1 id="tab1" onClick={() => setState({ engine: 'engine1' })}/>
    <Tab2 id="tab1" onClick={() => setState({ engine: 'engine2' })}/>
  </div>
</SearchProvider>

```

---

<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: [November 25, 2019, 11:12am UTC](https://discuss.elastic.co/t/how-to-implement-proximity-search-in-app-search/203966/12 "2019-11-25T11:12:21Z")

</div>

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