# Best practice for making a new index in ElasticSearch?

**URL:** <https://discuss.elastic.co/t/best-practice-for-making-a-new-index-in-elasticsearch/43245>\
**Category:** Elasticsearch\
**Created:** [March 2, 2016, 12:34pm UTC](https://discuss.elastic.co/t/best-practice-for-making-a-new-index-in-elasticsearch/43245 "2016-03-02T12:34:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![stevebissett](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stevebissett/32/7983_2.png) [@stevebissett](https://discuss.elastic.co/u/stevebissett)\
**Post date:** [March 2, 2016, 12:34pm UTC](https://discuss.elastic.co/t/best-practice-for-making-a-new-index-in-elasticsearch/43245/1 "2016-03-02T12:34:30Z")

</div>

I am new to ElasticSearch. I am using it to search variables within market research surveys.

```
survey_id: 100
name: gender
label: Gender
value_labels: {0 => Male, 1 => Female}

```

I have about 400 surveys with around 200000 variables.

I never need to search for variables for more than one survey at a time.

Should I be making a new index for each survey, or should I have a field called survey\_id which I filter on each time I search.?

What is the best practice here?

My current search is as follows:

```
GET /search_variables/variables/_search
{
    "query": {
      "bool": {
        "must": {
          "match": {
            "search_text": {
              "query": "BMW",
              "operator": "and"
            }
          }
        },
        
        "must_not": {
          "match": {
            "search_text": {
              "query": "",
              "operator": "or"
            }
          }
        }
      }
    }
}

```

I have been using `filter` and `term` with the above.

```
        "filter": {
             "term": {
             "survey_id": 12
             }
         }
```

---

<div class="post-metadata">

**Author:** ![ddorian43](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ddorian43/32/36093_2.png) [@ddorian43](https://discuss.elastic.co/u/ddorian43)\
**Post date:** [March 2, 2016, 1:35pm UTC](https://discuss.elastic.co/t/best-practice-for-making-a-new-index-in-elasticsearch/43245/2 "2016-03-02T13:35:37Z")

</div>

Filtering on survey\_id is the right approach. You can also \_route on survey\_id(need to do so also when you insert) so the query gets executed on 1 shard.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [March 3, 2016, 6:45am UTC](https://discuss.elastic.co/t/best-practice-for-making-a-new-index-in-elasticsearch/43245/3 "2016-03-03T06:45:06Z")

</div>

I wouldn't bother routing like that to be honest, it just adds complexity where it isn't really needed.

> [@stevebissett](#):
>
> I have about 400 surveys with around 200000 variables.

This will be your biggest problem, you may run into a mapping explosion with all those fields. The only good way around that is to denormalise, or maybe try putting similar surveys into the same index (and thus have more than one index).

---

<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 5, 2017, 11:11pm UTC](https://discuss.elastic.co/t/best-practice-for-making-a-new-index-in-elasticsearch/43245/4 "2017-07-05T23:11:46Z")

</div>


