# Performance issues with multiple field flt queries

**URL:** <https://discuss.elastic.co/t/performance-issues-with-multiple-field-flt-queries/5493>\
**Category:** Elasticsearch\
**Created:** [September 30, 2011, 7:37pm UTC](https://discuss.elastic.co/t/performance-issues-with-multiple-field-flt-queries/5493 "2011-09-30T19:37:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![crunchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/crunchy/32/3115_2.png) [@crunchy](https://discuss.elastic.co/u/crunchy)\
**Post date:** [September 30, 2011, 7:37pm UTC](https://discuss.elastic.co/t/performance-issues-with-multiple-field-flt-queries/5493/1 "2011-09-30T19:37:58Z")

</div>

Hi,

I have an index with roughly 16 million documents.

I am performing a filtered query, which is composed of a geodist filter and  
a bool query. The bool query has 3 flt\_field queries joined by should  
clauses. I'm getting queries that take up to 20 seconds, and was wondering  
what I can do to improve the performance.

My query was based off of what was being attempted in this thread (Fuzzy  
matching against multiple fields):  
[http://elasticsearch-users.115913.n3.nabble.com/Fuzzy-matching-against-multiple-fields-td2830262.html](http://elasticsearch-users.115913.n3.nabble.com/Fuzzy-matching-against-multiple-fields-td2830262.html)

Thanks.

---

<div class="post-metadata">

**Author:** ![crunchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/crunchy/32/3115_2.png) [@crunchy](https://discuss.elastic.co/u/crunchy)\
**Post date:** [October 3, 2011, 11:21pm UTC](https://discuss.elastic.co/t/performance-issues-with-multiple-field-flt-queries/5493/2 "2011-10-03T23:21:22Z")

</div>

The mapping for my index and a sample query is provided below. I've  
attempted to replace the bool query with 3 fuzzy like this field queries,  
with a single fuzzy like this field on the "pretty" field, and feel like  
this is where the query is slowing down.

I'd appreciate any insight into how to where I can improve the performance  
of the fuzzy string matching.

Here's the mapping for my index, where place is the document type.  
{'place': {'properties': {'address': {'type': 'string'},  
'aliases': {'type': 'string'},  
'areacode': {'type': 'string'},  
'city\_id': {'type': 'long'},  
'collection\_id': {'type': 'long'},  
'country\_id': {'type': 'long'},  
'county\_id': {'type': 'long'},  
'geo\_id': {'type': 'long'},  
'locality\_id': {'type': 'long'},  
'location': {'type': 'geo\_point'},  
'phonenumber': {'type': 'string'},  
'place\_type': {'type': 'long'},  
'pretty': {'type': 'string'},  
'province\_id': {'type': 'long'}}}}

Here's a sample query:  
{'query': {'filtered': {'filter': {'and': [{'terms': {'place\_type': [2]}},  
{'geo\_distance': {'distance':  
'0.3 mi',  
'location':  
{'lat': 37.797435,

'lon': -121.205995}}}]},  
'query': {'bool': {'minimum\_number\_should\_match': 1,  
'should':  
[{'fuzzy\_like\_this\_field': {'pretty': {'like\_text': 'Thomas Auto Sales',

```
            'max_query_terms': 2,
                                                                        
            'prefix_length': 2}}},

```

{'fuzzy\_like\_this\_field': {'phonenumber': {'like\_text': '4342345432',

```
            'max_query_terms': 2,
                                                                        
            'prefix_length': 2}}},

```

{'fuzzy\_like\_this\_field': {'address': {'like\_text': '123 Water St',

```
            'max_query_terms': 2,
                                                                        
            'prefix_length': 2}}}]}}}}}
```

---

<div class="post-metadata">

**Author:** ![crunchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/crunchy/32/3115_2.png) [@crunchy](https://discuss.elastic.co/u/crunchy)\
**Post date:** [October 3, 2011, 11:24pm UTC](https://discuss.elastic.co/t/performance-issues-with-multiple-field-flt-queries/5493/3 "2011-10-03T23:24:21Z")

</div>

The mapping for my index and a sample query is provided below.

Here's the mapping for my index, where place is the document type.

{'place': {'properties': {'address': {'type': 'string'},  
'aliases': {'type': 'string'},  
'areacode': {'type': 'string'},  
'city\_id': {'type': 'long'},  
'collection\_id': {'type': 'long'},  
'country\_id': {'type': 'long'},  
'county\_id': {'type': 'long'},  
'geo\_id': {'type': 'long'},  
'locality\_id': {'type': 'long'},  
'location': {'type': 'geo\_point'},  
'phonenumber': {'type': 'string'},  
'place\_type': {'type': 'long'},  
'pretty': {'type': 'string'},  
'province\_id': {'type': 'long'}}}}

Here's a sample query:

curl -XGET '[http://localhost:9200/my\_places/place/\_search](http://localhost:9200/my_places/place/_search)' -d

{'query': {'filtered': {'filter': {'and': [{'terms': {'place\_type': [2]}},

```
                                       {'geo_distance': {'distance': 

```

'0.3 mi',

```
                                                         'location': 

```

{'lat': 37.797435,

'lon': -121.205995}}}]},

```
                    'query': {'bool': {'minimum_number_should_match': 1,

                                       'should': 

```

[{'fuzzy\_like\_this\_field': {'pretty': {'like\_text': 'Thomas Auto Sales',

```
            'max_query_terms': 2,

                                                                        
            'prefix_length': 2}}},

```

{'fuzzy\_like\_this\_field': {'phonenumber': {'like\_text': '4342345432',

```
            'max_query_terms': 2,

                                                                        
            'prefix_length': 2}}},

```

{'fuzzy\_like\_this\_field': {'address': {'like\_text': '123 Water St',

```
            'max_query_terms': 2,

                                                                        
            'prefix_length': 2}}}]}}}}}

```

I've attempted to replace the bool query with 3 fuzzy like this field  
queries, with a single fuzzy like this field on the "pretty" field, and feel  
like this is where the query is slowing down.

I'd appreciate any insight into how to where I can improve the performance  
of the fuzzy string matching.

Thanks.

---

<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 6, 2017, 3:52am UTC](https://discuss.elastic.co/t/performance-issues-with-multiple-field-flt-queries/5493/4 "2017-07-06T03:52:56Z")

</div>


