# Reading analyzed fields as not-analyzed, and excluding parts of not-analyzed fields

**URL:** <https://discuss.elastic.co/t/reading-analyzed-fields-as-not-analyzed-and-excluding-parts-of-not-analyzed-fields/28727>\
**Category:** Elasticsearch\
**Created:** [September 5, 2015, 10:18pm UTC](https://discuss.elastic.co/t/reading-analyzed-fields-as-not-analyzed-and-excluding-parts-of-not-analyzed-fields/28727 "2015-09-05T22:18:22Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![LansK](https://avatars.discourse-cdn.com/v4/letter/l/dc4da7/32.png) [@LansK](https://discuss.elastic.co/u/LansK)\
**Post date:** [September 5, 2015, 10:18pm UTC](https://discuss.elastic.co/t/reading-analyzed-fields-as-not-analyzed-and-excluding-parts-of-not-analyzed-fields/28727/1 "2015-09-05T22:18:22Z")

</div>

I have a field whose mapping defaulted to analyzed that I would like to search over (for terms) as if it were not-analyzed. Is there a way to do that without re-indexing? (The problem I am encountering is discussed here: [https://www.elastic.co/guide/en/elasticsearch/guide/current/aggregations-and-analysis.html](https://www.elastic.co/guide/en/elasticsearch/guide/current/aggregations-and-analysis.html) )

In a separate but related problem, I have a field that contains URLS that can end with a variety of variables, some of which I may not want to factor into a result set for a unique terms aggregation. An example would be something like “user/profile?=1234” or “user/profile/1234,” where I would want to count both of these as a hit for the term “user/profile” and only as a hit for that term.

There are times where I would want "profile?=1234" or "/1234" and times where I would not want them. Is there also a way to include or exclude certain things like this from a search? And if I cannot exclude or include things like this, what might be the best solution to this issue when adding my data to elasticsearch?

---

<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:** [September 5, 2015, 11:27pm UTC](https://discuss.elastic.co/t/reading-analyzed-fields-as-not-analyzed-and-excluding-parts-of-not-analyzed-fields/28727/2 "2015-09-05T23:27:05Z")

</div>

Once it's been analysed you cannot do anything other than reindex to un-analyse it. You should use a multi-field mapping to create the analysed and then an additional un-analysed (ie `.raw`) field.

You second one also sounds like it could be solved by using multifields.

---

<div class="post-metadata">

**Author:** ![LansK](https://avatars.discourse-cdn.com/v4/letter/l/dc4da7/32.png) [@LansK](https://discuss.elastic.co/u/LansK)\
**Post date:** [September 6, 2015, 5:56pm UTC](https://discuss.elastic.co/t/reading-analyzed-fields-as-not-analyzed-and-excluding-parts-of-not-analyzed-fields/28727/3 "2015-09-06T17:56:24Z")

</div>

Thank you. I looked up multifields and can see the application to my first issue, but I was a bit unsure of their application to my second issue (counting "user/profile?=1234" or "user/profile/1234" as a hit for just "user/profile"). Could you elaborate on the second problem for me? If I now copy all urls to a non-indexed "raw" field, how might I perform a search that would equate the first two examples as a hit for just "user/profile" in an aggregation where "user/profile" would be a unique term and any extraneous text following "user/profile" (like ?=1234) would just count as a hit for the unique term "user/profile"?

---

<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:** [September 6, 2015, 11:54pm UTC](https://discuss.elastic.co/t/reading-analyzed-fields-as-not-analyzed-and-excluding-parts-of-not-analyzed-fields/28727/4 "2015-09-06T23:54:52Z")

</div>

Yeah perhaps that isn't the best use. Are you using Logstash? Because you could split that out into its own field there.

---

<div class="post-metadata">

**Author:** ![LansK](https://avatars.discourse-cdn.com/v4/letter/l/dc4da7/32.png) [@LansK](https://discuss.elastic.co/u/LansK)\
**Post date:** [September 7, 2015, 6:49am UTC](https://discuss.elastic.co/t/reading-analyzed-fields-as-not-analyzed-and-excluding-parts-of-not-analyzed-fields/28727/5 "2015-09-07T06:49:59Z")

</div>

I am using logstash. Can you elaborate a bit more on what you are proposing? Are you saying to have 3 url fields and to have logstash take the incoming url data and copy it to a new field (after removing the extraneous text)? Sorry I am not following so well.

---

<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:** [September 7, 2015, 7:10am UTC](https://discuss.elastic.co/t/reading-analyzed-fields-as-not-analyzed-and-excluding-parts-of-not-analyzed-fields/28727/6 "2015-09-07T07:10:50Z")

</div>

I was thinking that you could break the `user/profile?=1234` or `user/profile/1234` bits out into their own field and then drop everything after the profile part.

---

<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:51pm UTC](https://discuss.elastic.co/t/reading-analyzed-fields-as-not-analyzed-and-excluding-parts-of-not-analyzed-fields/28727/7 "2017-07-05T23:51:49Z")

</div>


