# How to query the stored, un-analyzed, form of an analyzed field?

**URL:** <https://discuss.elastic.co/t/how-to-query-the-stored-un-analyzed-form-of-an-analyzed-field/13334>\
**Category:** Elasticsearch\
**Created:** [August 26, 2013, 9:28pm UTC](https://discuss.elastic.co/t/how-to-query-the-stored-un-analyzed-form-of-an-analyzed-field/13334 "2013-08-26T21:28:04Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Rafal\_Kuc\_3](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rafal_kuc_3/32/799_2.png) [@Rafal\_Kuc\_3](https://discuss.elastic.co/u/Rafal_Kuc_3)\
**Post date:** [August 26, 2013, 9:32pm UTC](https://discuss.elastic.co/t/how-to-query-the-stored-un-analyzed-form-of-an-analyzed-field/13334/2 "2013-08-26T21:32:38Z")

</div>

Hello!

You can create a multifield ([http://www.elasticsearch.org/guide/reference/mapping/multi-field-type/](http://www.elasticsearch.org/guide/reference/mapping/multi-field-type/)) for the name field which would have two fields. It would look something like this:

"name" : {

"type" : "multi\_field",

"fields" : {

```
"name" : {"type" : "string", "index" : "analyzed", "analyzer": "name_synonym", "store": "yes"},

"not_analyzed" : {"type" : "string", "index" : "not_analyzed"}

```

}

}

You would query the 'name' field when you want to query the analyzed field and you would use the 'name.not\_analyzed' name when you would like to query the non-analyzed form of the field.

Hope that helps.

_--_

Regards,

Rafał Kuć

Sematext :: [http://sematext.com/](http://sematext.com/) _:: Solr - Lucene - ElasticSearch_

I'm having trouble figuring out how the query (search) the 'stored' form of a field that has an analyzer. I need to be able to search for both the unmodified words, and the synonym mapping I've created at different times.

Take, for example, the following:

{

"settings" : {

```
"analysis" : {

    "analyzer" : {

        "name_synonym" : {

            "type" : "custom",

            "tokenizer" : "whitespace",

            "filter" : ["lowercase", "name_synonym"]

        }

     },

     "filter" : {

        "name_synonym" : {

            "type" : "synonym",

            "synonyms_path" : "analysis/name_synonyms.txt"

        }

     }

}

```

},

"mappings" : {

```
"record" : {

    "properties" : {

        "name" : { "type" : "string", "analyzer" : "name_synonym", "store" : "yes" }

    }

}

```

}

}

What would I use in my query to indicate that it should only query the stored form, and not the analyzed form? That is to say in this example, I sometimes want to query for "Chris," and have "Kris," match (works in a normal field query with the analyzer in-place), but other times I only want to match "Chris" (doesn't work with the analyzer in place).

The current, relevant section of my query looks like this, which searches the analyzed form.

{

'fquery' =\> {

```
    '_name' =&gt; 'recordName',

    'query' =&gt; {

             'field' =&gt; {

                  'name' =&gt; 'chris'

                }

           }

      }

```

}

Any advice would be greatly appreciated!

--

You received this message because you are subscribed to the Google Groups "elasticsearch" group.

To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).

For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

_[View the full topic](https://discuss.elastic.co/t/how-to-query-the-stored-un-analyzed-form-of-an-analyzed-field/13334)._
