# Unmapped, searchable JSON field

**URL:** <https://discuss.elastic.co/t/unmapped-searchable-json-field/6402>\
**Category:** Elasticsearch\
**Created:** [January 16, 2012, 5:13pm UTC](https://discuss.elastic.co/t/unmapped-searchable-json-field/6402 "2012-01-16T17:13:12Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![MarcusLongmuir](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@MarcusLongmuir](https://discuss.elastic.co/u/MarcusLongmuir)\
**Post date:** [January 16, 2012, 5:13pm UTC](https://discuss.elastic.co/t/unmapped-searchable-json-field/6402/1 "2012-01-16T17:13:12Z")

</div>

I'd like to be able to store JSON in a field of a document that is  
searchable as a string, but unmapped so that I can store any structure  
within this field without conflict.

I've experimented with different mappings, none of which allow me to  
perform a text search on the field and my setup makes it cumbersome to  
rapidly modify settings to find the one that works.

I assume this is possible and I've just been unable to discover the  
correct combination of settings. If anyone can help me out I'd  
appreciate it.

Thanks

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [January 17, 2012, 9:41am UTC](https://discuss.elastic.co/t/unmapped-searchable-json-field/6402/2 "2012-01-17T09:41:03Z")

</div>

You mean within a json field, you will have a json value encoded into that  
string? If so, whats the problem with it?

On Mon, Jan 16, 2012 at 7:13 PM, marcuslongmuir [marcuslongmuir@me.com](mailto:marcuslongmuir@me.com)wrote:

> I'd like to be able to store JSON in a field of a document that is  
> searchable as a string, but unmapped so that I can store any structure  
> within this field without conflict.
> 
> I've experimented with different mappings, none of which allow me to  
> perform a text search on the field and my setup makes it cumbersome to  
> rapidly modify settings to find the one that works.
> 
> I assume this is possible and I've just been unable to discover the  
> correct combination of settings. If anyone can help me out I'd  
> appreciate it.
> 
> Thanks

---

<div class="post-metadata">

**Author:** ![MarcusLongmuir](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@MarcusLongmuir](https://discuss.elastic.co/u/MarcusLongmuir)\
**Post date:** [January 18, 2012, 3:18am UTC](https://discuss.elastic.co/t/unmapped-searchable-json-field/6402/3 "2012-01-18T03:18:06Z")

</div>

This is the functionality I would like to achieve, but without  
explicitly setting the JSON structure as a string in the document. I  
tried setting the mapping type to "String", but I was unable to search  
on the field.

On Jan 17, 9:41 am, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> You mean within a json field, you will have a json value encoded into that  
> string? If so, whats the problem with it?
> 
> On Mon, Jan 16, 2012 at 7:13 PM, marcuslongmuir [marcuslongm...@me.com](mailto:marcuslongm...@me.com)wrote:
> 
> > I'd like to be able to store JSON in a field of a document that is  
> > searchable as a string, but unmapped so that I can store any structure  
> > within this field without conflict.
> 
> > I've experimented with different mappings, none of which allow me to  
> > perform a text search on the field and my setup makes it cumbersome to  
> > rapidly modify settings to find the one that works.
> 
> > I assume this is possible and I've just been unable to discover the  
> > correct combination of settings. If anyone can help me out I'd  
> > appreciate it.
> 
> > Thanks

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [January 18, 2012, 4:10am UTC](https://discuss.elastic.co/t/unmapped-searchable-json-field/6402/4 "2012-01-18T04:10:42Z")

</div>

On Tue, 2012-01-17 at 19:18 -0800, marcuslongmuir wrote:

> This is the functionality I would like to achieve, but without  
> explicitly setting the JSON structure as a string in the document. I  
> tried setting the mapping type to "String", but I was unable to search  
> on the field.

The mapping type should be 'string', not 'String'.

Here is an example: [Index a doc which contains a JSON-encoded string · GitHub](https://gist.github.com/1630868)

I index a doc which contains a JSON encoded string (so in the curl  
statement, that string is double-encoded).

This automatically creates the 'json' field and sets its type to  
'string', and analyzes its contents with the default analyzer.

Then I demonstrate a search on the contents of the JSON, and finally  
show all the terms stored in the 'json' field, indicating how the string  
has been analyzed.

clint

---

<div class="post-metadata">

**Author:** ![MarcusLongmuir](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@MarcusLongmuir](https://discuss.elastic.co/u/MarcusLongmuir)\
**Post date:** [January 20, 2012, 3:13am UTC](https://discuss.elastic.co/t/unmapped-searchable-json-field/6402/5 "2012-01-20T03:13:35Z")

</div>

Thanks for the solution. I would definitely be using this method were  
it not for a rather difficult limitation.

Unfortunately without having at least some redundancy I can't do this  
as I need to be able to return the document straight from a search  
result without the overhead of parsing it.

Is there no mapping setup that would allow me to simply set the  
indexing of the field to a string and have the structure processed the  
same was as if it were double encoded as you demonstrate in your gist?

Thanks

On Jan 18, 4:10 am, Clinton Gormley [cl...@traveljury.com](mailto:cl...@traveljury.com) wrote:

> On Tue, 2012-01-17 at 19:18 -0800, marcuslongmuir wrote:
> 
> > This is the functionality I would like to achieve, but without  
> > explicitly setting theJSONstructure as astringin the document. I  
> > tried setting the mapping type to "String", but I was unable to search  
> > on the field.
> 
> The mapping type should be 'string', not 'String'.
> 
> Here is an example:[Index a doc which contains a JSON-encoded string · GitHub](https://gist.github.com/1630868)
> 
> I index a doc which contains aJSONencodedstring(so in the curl  
> statement, thatstringis double-encoded).
> 
> This automatically creates the 'json' field and sets its type to  
> 'string', and analyzes its contents with the default analyzer.
> 
> Then I demonstrate a search on the contents of theJSON, and finally  
> show all the terms stored in the 'json' field, indicating how thestring  
> has been analyzed.
> 
> clint

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [January 20, 2012, 3:05pm UTC](https://discuss.elastic.co/t/unmapped-searchable-json-field/6402/6 "2012-01-20T15:05:13Z")

</div>

No, there isn't one.

On Fri, Jan 20, 2012 at 5:13 AM, marcuslongmuir [marcuslongmuir@me.com](mailto:marcuslongmuir@me.com)wrote:

> Thanks for the solution. I would definitely be using this method were  
> it not for a rather difficult limitation.
> 
> Unfortunately without having at least some redundancy I can't do this  
> as I need to be able to return the document straight from a search  
> result without the overhead of parsing it.
> 
> Is there no mapping setup that would allow me to simply set the  
> indexing of the field to a string and have the structure processed the  
> same was as if it were double encoded as you demonstrate in your gist?
> 
> Thanks
> 
> On Jan 18, 4:10 am, Clinton Gormley [cl...@traveljury.com](mailto:cl...@traveljury.com) wrote:
> 
> > On Tue, 2012-01-17 at 19:18 -0800, marcuslongmuir wrote:
> > 
> > > This is the functionality I would like to achieve, but without  
> > > explicitly setting theJSONstructure as astringin the document. I  
> > > tried setting the mapping type to "String", but I was unable to search  
> > > on the field.
> > 
> > The mapping type should be 'string', not 'String'.
> > 
> > Here is an example:[Index a doc which contains a JSON-encoded string · GitHub](https://gist.github.com/1630868)
> > 
> > I index a doc which contains aJSONencodedstring(so in the curl  
> > statement, thatstringis double-encoded).
> > 
> > This automatically creates the 'json' field and sets its type to  
> > 'string', and analyzes its contents with the default analyzer.
> > 
> > Then I demonstrate a search on the contents of theJSON, and finally  
> > show all the terms stored in the 'json' field, indicating how thestring  
> > has been analyzed.
> > 
> > clint

---

<div class="post-metadata">

**Author:** ![MarcusLongmuir](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@MarcusLongmuir](https://discuss.elastic.co/u/MarcusLongmuir)\
**Post date:** [January 21, 2012, 12:03am UTC](https://discuss.elastic.co/t/unmapped-searchable-json-field/6402/7 "2012-01-21T00:03:17Z")

</div>

Ok. Thanks for the solution. I'll have to put the encoding in the  
application layer, not too much of an overhead.

On Jan 20, 3:05 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> No, there isn't one.
> 
> On Fri, Jan 20, 2012 at 5:13 AM, marcuslongmuir [marcuslongm...@me.com](mailto:marcuslongm...@me.com)wrote:
> 
> > Thanks for the solution. I would definitely be using this method were  
> > it not for a rather difficult limitation.
> 
> > Unfortunately without having at least some redundancy I can't do this  
> > as I need to be able to return the document straight from a search  
> > result without the overhead of parsing it.
> 
> > Is there no mapping setup that would allow me to simply set the  
> > indexing of the field to a string and have the structure processed the  
> > same was as if it were double encoded as you demonstrate in your gist?
> 
> > Thanks
> 
> > On Jan 18, 4:10 am, Clinton Gormley [cl...@traveljury.com](mailto:cl...@traveljury.com) wrote:
> > 
> > > On Tue, 2012-01-17 at 19:18 -0800, marcuslongmuir wrote:
> > > 
> > > > This is the functionality I would like to achieve, but without  
> > > > explicitly setting theJSONstructure as astringin the document. I  
> > > > tried setting the mapping type to "String", but I was unable to search  
> > > > on the field.
> 
> > > The mapping type should be 'string', not 'String'.
> 
> > > Here is an example:[Index a doc which contains a JSON-encoded string · GitHub](https://gist.github.com/1630868)
> 
> > > I index a doc which contains aJSONencodedstring(so in the curl  
> > > statement, thatstringis double-encoded).
> 
> > > This automatically creates the 'json' field and sets its type to  
> > > 'string', and analyzes its contents with the default analyzer.
> 
> > > Then I demonstrate a search on the contents of theJSON, and finally  
> > > show all the terms stored in the 'json' field, indicating how thestring  
> > > has been analyzed.
> 
> > > clint

---

<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 6, 2017, 3:41am UTC](https://discuss.elastic.co/t/unmapped-searchable-json-field/6402/8 "2017-07-06T03:41:55Z")

</div>


