# Search through tags with more like this query

**URL:** <https://discuss.elastic.co/t/search-through-tags-with-more-like-this-query/13964>\
**Category:** Elasticsearch\
**Created:** [October 16, 2013, 7:43am UTC](https://discuss.elastic.co/t/search-through-tags-with-more-like-this-query/13964 "2013-10-16T07:43:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Quang\_Dung](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/quang_dung/32/2043_2.png) [@Quang\_Dung](https://discuss.elastic.co/u/Quang_Dung)\
**Post date:** [October 16, 2013, 7:43am UTC](https://discuss.elastic.co/t/search-through-tags-with-more-like-this-query/13964/1 "2013-10-16T07:43:13Z")

</div>

Hi everyone,

I have a question regarding the more like this query Currently, I'm making  
a solution to match "more like this" product based on its tags.id . I have  
the \_mapping of product which is something like this :

{  
name(:string),  
tags: [{id(:integer}, {id(:integer)}]  
}

I have tried something like this :  
elasticsearch:9200/\<index\_name\>/product/\_mlt?mlt\_fields=tags.id but it  
doesn't seem to work. I got the error :  
{"error":"NumberFormatException[For input string: "[67773, 71354, 68265,  
70599, 81670, 191917]"]","status":500}

Elasticsearch doesn't work automagically which is great. But I'm not clear  
what is problem I have and what is a good way to solve this problem.

Thanks for reading.

--  
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).

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [October 16, 2013, 8:23am UTC](https://discuss.elastic.co/t/search-through-tags-with-more-like-this-query/13964/2 "2013-10-16T08:23:11Z")

</div>

Hey,

not sure on the top of my head, but I think, MLT queries need an analyzer,  
which creates char terms - where as numeric analyzers in lucene do not.  
This is the reason why MLT does not work with numbers. In your case a  
workaround might be easy, by just indexing the real tagnames and search for  
documents with the same tag (maybe you do not need MLT then).

If you want to know more, see

> <https://github.com/elastic/elasticsearch/issues/3252#issuecomment-20405814>
>
> According to the documentation:
> 
> Note: In order to use the mlt feature a mlt\_fie…ld needs to be either be stored, store term\_vector or source needs to be enabled.
> 
> But,running this:
> 
> \`\`\`
> curl -XPOST http://localhost:9200/foo
> curl -XPUT http://localhost:9200/foo/bar/\_mapping -d '{ "bar": { "dynamic": "strict", "properties": { "id": { "type": "integer", "index": "not\_analyzed" }, "content": { "type": "string", "analyzer": "standard" }}}}'
> 
> curl -XPUT http://localhost:9200/foo/bar/1 -d '{"id":1, "content":"foo bar foo2 bar2 foo3 bar3"}'
> curl -XPUT http://localhost:9200/foo/bar/2 -d '{"id":2, "content":"foo3 bar3 foo4 bar4"}'
> 
> 
> curl -XGET 'http://localhost:9200/foo/bar/1/\_mlt?mlt\_fields=content&min\_term\_freq=1&min\_doc\_freq=1'
> curl -XGET 'http://localhost:9200/foo/bar/1/\_mlt?min\_term\_freq=1&min\_doc\_freq=1'
> \`\`\`
> 
> fails(second query) with:
> {"error":"MapperParsingException\[failed to parse \[id\]\]; nested: ElasticSearchIllegalStateException\[Field should have either a string, numeric or binary value\]; ","status":400}
> 
> This is basically because here(for example):
> https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/index/mapper/core/IntegerFieldMapper.java#L356-L360
> 
> The numeric value is not actually used unless the field is stored.
> 
> Then here:
> https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/action/mlt/TransportMoreLikeThisAction.java#L293-L303
> 
> if you can't read it, it will just thrown an exception.

--Alex

On Wed, Oct 16, 2013 at 9:43 AM, Quang Dũng [nxqd.inbox@gmail.com](mailto:nxqd.inbox@gmail.com) wrote:

> Hi everyone,
> 
> I have a question regarding the more like this query Currently, I'm making  
> a solution to match "more like this" product based on its tags.id . I  
> have the \_mapping of product which is something like this :
> 
> {  
> name(:string),  
> tags: [{id(:integer}, {id(:integer)}]  
> }
> 
> I have tried something like this :  
> elasticsearch:9200/\<index\_\*\*name\>/product/\_mlt?mlt\_fields=\*\*tags.id[http://tags.id/](http://tags.id/) but  
> it doesn't seem to work. I got the error :  
> {"error":"\*\*NumberFormatException[For input string: "[67773, 71354,  
> 68265, 70599, 81670, 191917]"]","status":500}
> 
> Elasticsearch doesn't work automagically which is great. But I'm not clear  
> what is problem I have and what is a good way to solve this problem.
> 
> Thanks for reading.
> 
> --  
> 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).

--  
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).

---

<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, 2:12am UTC](https://discuss.elastic.co/t/search-through-tags-with-more-like-this-query/13964/3 "2017-07-06T02:12:14Z")

</div>

Closed on July 6, 2017, 2:12am UTC


