# ES query on raw subfield

**URL:** <https://discuss.elastic.co/t/es-query-on-raw-subfield/63494>\
**Category:** Elasticsearch\
**Created:** [October 20, 2016, 11:24am UTC](https://discuss.elastic.co/t/es-query-on-raw-subfield/63494 "2016-10-20T11:24:43Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![valerioorfano](https://avatars.discourse-cdn.com/v4/letter/v/ba9def/32.png) [@valerioorfano](https://discuss.elastic.co/u/valerioorfano)\
**Post date:** [October 20, 2016, 11:24am UTC](https://discuss.elastic.co/t/es-query-on-raw-subfield/63494/1 "2016-10-20T11:24:43Z")

</div>

Hi there, I m struggling with raw not\_analyzed subfield

i ve the following conf

PUT /mise/wo-patent-document/\_mapping  
{  
"wo-patent-document": {  
"properties": {  
"wo-patent-document": {  
"properties": {  
"claims\_IT": {  
"type": "string",  
"analyzer": "italian",  
"term\_vector" : "with\_positions\_offsets",  
"fields": {  
"raw": {  
"type": "string",  
"index": "not\_analyzed",  
"term\_vector" : "with\_positions\_offsets",  
"ignore\_above" : 256  
}  
}  
}  
}  
}  
}  
}  
}

Now im tryin to query the raw field with match\_phrase:

GET /mise/wo-patent-document/\_search  
{  
"query": {  
"match\_phrase": {  
"wo-patent-document.description\_IT.raw": "piezoelettriche"  
}  
}  
}

It doesnt work, Can i use my "raw" subfiel for "not\_analyzed" query?

The same query on "wo-patent-document.description\_IT" works!

Thank you very much

---

<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 20, 2016, 11:46am UTC](https://discuss.elastic.co/t/es-query-on-raw-subfield/63494/2 "2016-10-20T11:46:53Z")

</div>

Please format your code.

And provide a typical document which should match.

---

<div class="post-metadata">

**Author:** ![valerioorfano](https://avatars.discourse-cdn.com/v4/letter/v/ba9def/32.png) [@valerioorfano](https://discuss.elastic.co/u/valerioorfano)\
**Post date:** [October 20, 2016, 12:19pm UTC](https://discuss.elastic.co/t/es-query-on-raw-subfield/63494/3 "2016-10-20T12:19:27Z")

</div>

Hi David,

PUT /mise/wo-patent-document/\_mapping  
{  
"wo-patent-document": {  
"properties": {  
"wo-patent-document": {  
"properties": {  
"description\_IT": {  
"type": "string",  
"analyzer": "italian",  
"term\_vector" : "with\_positions\_offsets",  
"fields": {  
"raw": {  
"type": "string",  
"index": "not\_analyzed",  
"term\_vector" : "with\_positions\_offsets",  
"ignore\_above" : 256  
}  
}  
}  
}  
}  
}  
}  
}

I want to query using analyzed and not\_analyzed field "description\_IT"  
The Query:

GET /mise/wo-patent-document/\_search  
{  
"query": {  
"match\_phrase": {  
"wo-patent-document.description\_IT": "che impiegano ceramiche piezoelettriche"  
}  
},  
"highlight" : {  
"fields" : {  
"wo-patent-document.description\_IT" : {}  
},  
"fragment\_size" : "300",  
"number\_of\_fragments" : "1"  
}  
}  
retuns one document but it doesn t highlight the word "che" because stop word. This result is fine

GET /mise/wo-patent-document/\_search  
{  
"query": {  
"match\_phrase": {  
"wo-patent-document.description\_IT.raw": "che impiegano ceramiche piezoelettriche"  
}  
},  
"highlight" : {  
"fields" : {  
"wo-patent-document.description\_IT.raw" : {}  
},  
"fragment\_size" : "300",  
"number\_of\_fragments" : "1"  
}  
}  
returns 0 documents. I would expect to return 1 document.

IT seems the raw subfield is not taken into account.

Content snippet of descriptio\_IT field:

"Per aumentare la velocità di selezione ed incrementare \n25 \nla produzione si è sostituito l’utilizzo di tradizionali \n2\n \nelettromagneti di azionamento delle punte con soluzioni \nche impiegano ceramiche piezoelettriche, riducendo in \nquesto modo sia il tempo di attuazione che i consumi \nderivanti dalle bobine. \n5 \nQuesti attuatori sono dotati di lamine piezoelettriche \nche, a seconda della polarizzazione elettrica a cui sono \nsottoposte, si muovono in alto od in basso (considerando \nper semplicità espositiva le punte allineate in altezza \ne rivolte orizzontalmente),"

My ES version 2.3.4

Rgds valerio

---

<div class="post-metadata">

**Author:** ![valerioorfano](https://avatars.discourse-cdn.com/v4/letter/v/ba9def/32.png) [@valerioorfano](https://discuss.elastic.co/u/valerioorfano)\
**Post date:** [October 20, 2016, 12:22pm UTC](https://discuss.elastic.co/t/es-query-on-raw-subfield/63494/4 "2016-10-20T12:22:16Z")

</div>

Sorry but from the preview it seems to be ok. If you copy/paste on notepad you shouyld display the correct format

PUT /mise/wo-patent-document/\_mapping  
{  
"wo-patent-document": {  
"properties": {  
"wo-patent-document": {  
"properties": {  
"claims\_IT": {  
"type": "string",  
"analyzer": "italian",  
"term\_vector" : "with\_positions\_offsets",  
"fields": {  
"raw": {  
"type": "string",  
"index": "not\_analyzed",  
"term\_vector" : "with\_positions\_offsets",  
"ignore\_above" : 256  
}  
}  
}  
}  
}  
}  
}  
}

GET /mise/wo-patent-document/\_search  
{  
"query": {  
"match\_phrase": {  
"wo-patent-document.description\_IT": "che impiegano ceramiche piezoelettriche"  
}  
},  
"highlight" : {  
"fields" : {  
"wo-patent-document.description\_IT" : {}  
},  
"fragment\_size" : "300",  
"number\_of\_fragments" : "1"  
}  
}

---

<div class="post-metadata">

**Author:** ![valerioorfano](https://avatars.discourse-cdn.com/v4/letter/v/ba9def/32.png) [@valerioorfano](https://discuss.elastic.co/u/valerioorfano)\
**Post date:** [October 21, 2016, 8:01am UTC](https://discuss.elastic.co/t/es-query-on-raw-subfield/63494/5 "2016-10-21T08:01:14Z")

</div>

Hi any news?

Any query run over the raw subfield return 0 docuemts. Even

GET /mise/wo-patent-document/\_search  
{  
"query": {  
"wildcard" : {  
"wo-patent-document.description\_IT.raw" : {  
"value" : "\*"  
}  
}  
}  
}

why????

---

<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 21, 2016, 8:15am UTC](https://discuss.elastic.co/t/es-query-on-raw-subfield/63494/6 "2016-10-21T08:15:09Z")

</div>

Should I write this again?

> [@dadoonet](#):
>
> Please format your code.
> 
> And provide a typical document which should match.

You have here a typical example of what we would like to see when users are asking for help. [About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21/1)

Can you provide such a script?  
And please format your code using `</>` icon. It will make your post more readable.

---

<div class="post-metadata">

**Author:** ![valerioorfano](https://avatars.discourse-cdn.com/v4/letter/v/ba9def/32.png) [@valerioorfano](https://discuss.elastic.co/u/valerioorfano)\
**Post date:** [October 21, 2016, 1:24pm UTC](https://discuss.elastic.co/t/es-query-on-raw-subfield/63494/7 "2016-10-21T13:24:05Z")

</div>

No need.

I've fixed my issue.

Rgds valeiro

---

<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:** [October 21, 2016, 10:26pm UTC](https://discuss.elastic.co/t/es-query-on-raw-subfield/63494/8 "2016-10-21T22:26:32Z")

</div>

How did you fix it? Sharing may help others in future 🙂

---

<div class="post-metadata">

**Author:** ![valerioorfano](https://avatars.discourse-cdn.com/v4/letter/v/ba9def/32.png) [@valerioorfano](https://discuss.elastic.co/u/valerioorfano)\
**Post date:** [October 27, 2016, 10:33am UTC](https://discuss.elastic.co/t/es-query-on-raw-subfield/63494/9 "2016-10-27T10:33:07Z")

</div>

With pleasure 😄

I' ve saved into my field "description" the text content of a pdf file so it is quite big.

I need to make multipe search over this field. One of this search is an "exact match phrase". Initially i thought to use a raw "not\_indexed" field for this kind of query (description.raw). For relatively small description field it works fine, but when the content of the description field is big , the content of the description.raw field is big too, and query over the raw field returns 0 document, always!! Or at least this is what i tested (even with "ignore\_above": 256 )

I realized that for exact match phrase i could simply use a normal string field with "standard" tokenizer. And i decided to go for it!

Any thought?

Rgds valerio

---

<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, 10:09pm UTC](https://discuss.elastic.co/t/es-query-on-raw-subfield/63494/10 "2017-07-05T22:09:06Z")

</div>


