# Help needed in making a query for elastic search

**URL:** <https://discuss.elastic.co/t/help-needed-in-making-a-query-for-elastic-search/250477>\
**Category:** Elasticsearch\
**Created:** [September 30, 2020, 10:11am UTC](https://discuss.elastic.co/t/help-needed-in-making-a-query-for-elastic-search/250477 "2020-09-30T10:11:45Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![vishalYadav](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vishalyadav/32/76604_2.png) [@vishalYadav](https://discuss.elastic.co/u/vishalYadav)\
**Post date:** [September 30, 2020, 10:11am UTC](https://discuss.elastic.co/t/help-needed-in-making-a-query-for-elastic-search/250477/1 "2020-09-30T10:11:45Z")

</div>

Hey,I am working on a index which has 300 fieds in it.Now there is a requirement where i have to make 2 field irrelevent for searching in that index.As of now i am using `*.* `to search .  
i studied somewhere we can make enabled=false but that i cannot do becuase this index is used in some other scenerio as well.

current Query is

```auto
"bool":{"must":[{"query_string":{"query":"\"Java Developer\"","fields":["*.*"],"lenient":true}}]}}]

```

---

<div class="post-metadata">

**Author:** ![vishalYadav](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vishalyadav/32/76604_2.png) [@vishalYadav](https://discuss.elastic.co/u/vishalYadav)\
**Post date:** [September 30, 2020, 10:22am UTC](https://discuss.elastic.co/t/help-needed-in-making-a-query-for-elastic-search/250477/3 "2020-09-30T10:22:41Z")

</div>

"fields":["star.star"],( as star symbol is getting deleted)

---

<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 30, 2020, 1:40pm UTC](https://discuss.elastic.co/t/help-needed-in-making-a-query-for-elastic-search/250477/4 "2020-09-30T13:40:30Z")

</div>

Please format your code, logs or configuration files using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) and not the citation button. It will make your post more readable.

Or use markdown style like:

````
```
CODE
```

````

This is the icon to use if you are not using markdown format:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/e/7e6e239431ec2d71cbf1beef741f2e93e7cc762c.jpg)

There's a live preview panel for exactly this reasons.

Lots of people read these forums, and many of them will simply skip over a post that is difficult to read, because it's just too large an investment of their time to try and follow a wall of badly formatted text.  
If your goal is to get an answer to your questions, it's in your interest to make it as easy to read and understand as possible.  
Please update your post. That way `*.*` won't get replaced.

---

<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 30, 2020, 1:43pm UTC](https://discuss.elastic.co/t/help-needed-in-making-a-query-for-elastic-search/250477/5 "2020-09-30T13:43:35Z")

</div>

One of the thing I'm thinking of is to use [Field Level security](https://www.elastic.co/guide/en/elasticsearch/reference/current/field-level-security.html) with 2 different roles. One which has access and the other which has not.

Note that it probably requires a platinum license. You can start a trial anytime if you want to test it and switch back to basic if it does not fit your use case.

---

<div class="post-metadata">

**Author:** ![vishalYadav](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vishalyadav/32/76604_2.png) [@vishalYadav](https://discuss.elastic.co/u/vishalYadav)\
**Post date:** [October 1, 2020, 7:02am UTC](https://discuss.elastic.co/t/help-needed-in-making-a-query-for-elastic-search/250477/6 "2020-10-01T07:02:26Z")

</div>

hey,Can't we make changes to the query only to fit the case?

---

<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:** [October 1, 2020, 8:09am UTC](https://discuss.elastic.co/t/help-needed-in-making-a-query-for-elastic-search/250477/7 "2020-10-01T08:09:58Z")

</div>

You can specify the list of fields you want to search on using the query string query `fields` parameter (like you did with `"fields":["*.*"]` but by using actual list of field names) or with a [multi match query](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html).

---

<div class="post-metadata">

**Author:** ![vishalYadav](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vishalyadav/32/76604_2.png) [@vishalYadav](https://discuss.elastic.co/u/vishalYadav)\
**Post date:** [October 1, 2020, 10:47am UTC](https://discuss.elastic.co/t/help-needed-in-making-a-query-for-elastic-search/250477/8 "2020-10-01T10:47:38Z")

</div>

so specifying 298 fields would be a rigid solution,let's think of solution like this where in \_source there is option to include and exclude.

```auto
 "_source": {
      "includes": [
        "*.count",
        "meta.*"
      ],
      "excludes": [
        "meta.description",
        "meta.other.*"
      ]
    }

```

do we have this kind of option in "fields"?or maybe in multi\_match?  
Like where i will specify the fields to search..

```auto
"fields":{
"includes": [
        "*.*"
      ],
      "excludes": [
        "meta.description",
        "meta.other"
      ]
    }

```

---

<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:** [October 1, 2020, 1:51pm UTC](https://discuss.elastic.co/t/help-needed-in-making-a-query-for-elastic-search/250477/9 "2020-10-01T13:51:36Z")

</div>

> [@vishalYadav](#):
>
> do we have this kind of option in "fields"?or maybe in multi\_match?  
> Like where i will specify the fields to search.

No I don't believe so.

May be a feature request to open?

---

<div class="post-metadata">

**Author:** ![vishalYadav](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vishalyadav/32/76604_2.png) [@vishalYadav](https://discuss.elastic.co/u/vishalYadav)\
**Post date:** [October 4, 2020, 8:20am UTC](https://discuss.elastic.co/t/help-needed-in-making-a-query-for-elastic-search/250477/10 "2020-10-04T08:20:26Z")

</div>

Sure, maybe in future it could help me or the ones who's having a big index with 100's of fields

---

<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 1, 2020, 8:20am UTC](https://discuss.elastic.co/t/help-needed-in-making-a-query-for-elastic-search/250477/11 "2020-11-01T08:20:28Z")

</div>

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