# On the document multi-field search slow problem

**URL:** <https://discuss.elastic.co/t/on-the-document-multi-field-search-slow-problem/101922>\
**Category:** Elasticsearch\
**Created:** [September 27, 2017, 4:19am UTC](https://discuss.elastic.co/t/on-the-document-multi-field-search-slow-problem/101922 "2017-09-27T04:19:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![smithyj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/smithyj/32/26592_2.png) [@smithyj](https://discuss.elastic.co/u/smithyj)\
**Post date:** [September 27, 2017, 4:19am UTC](https://discuss.elastic.co/t/on-the-document-multi-field-search-slow-problem/101922/1 "2017-09-27T04:19:06Z")

</div>

## Problem Description

A document in the organization's index that contains all the department collections for this organization, such as

```auto
{
    id：1，
    org_name：'Google'，
    department_list：[
       {
           id: 1,
           name: 'financial department'
           ... (7 fields more)
       }
       ......(41666 object more )
   ]
}

```

But the document contains 41666 departments, because too many departments lead to search is very slow, search results time `43s`, please provide the idea to solve the problem, thank your!

## Whole Mapping

[https://github.com/elastic/elasticsearch/issues/26796](https://github.com/elastic/elasticsearch/issues/26796)

## Query DSL

```auto
{
    "size": 10,
    "query": {
        "bool": {
            "must": [
                {
                    "match_phrase": {
                        "_all": "tech"
                    }
                }
            ],
            "should": [
                {
                    "match_phrase": {
                        "name": {
                            "boost": 100,
                            "query": "tech"
                        }
                    }
                }
            ]
        }
    },
    "highlight": {
        "fields": {
            "*": {
                "pre_tags": [
                    "<em class=\"es-search-highlight\">"
                ],
                "post_tags": [
                    "</em>"
                ],
                "require_field_match": "false"
            }
        }
    }
}

```

## OS Configuration

> CPU: 2 Core 4 Thread  
> Memory: 4 GB  
> OS version: Ubuntu 16.5  
> Running environment：Rancher

---

<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 27, 2017, 5:12am UTC](https://discuss.elastic.co/t/on-the-document-multi-field-search-slow-problem/101922/2 "2017-09-27T05:12:39Z")

</div>

Are you searching for departments or for organizations?

What is the mapping? What does a query look like?

---

<div class="post-metadata">

**Author:** ![smithyj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/smithyj/32/26592_2.png) [@smithyj](https://discuss.elastic.co/u/smithyj)\
**Post date:** [September 27, 2017, 6:49am UTC](https://discuss.elastic.co/t/on-the-document-multi-field-search-slow-problem/101922/3 "2017-09-27T06:49:11Z")

</div>

The problem has been updated, please see

---

<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 27, 2017, 7:31am UTC](https://discuss.elastic.co/t/on-the-document-multi-field-search-slow-problem/101922/4 "2017-09-27T07:31:17Z")

</div>

Can you remove the highlighting part and test again?

---

<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 25, 2017, 7:31am UTC](https://discuss.elastic.co/t/on-the-document-multi-field-search-slow-problem/101922/5 "2017-10-25T07:31:30Z")

</div>

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