I just bumped into "more like this" functionality/api. Is there a 
possibility to combine the result from more_like_this with some additional 
search constraint?

I have two following ES query which works:

POST /h/B/_search
{
    "query":{
        "more_like_this" : {
            "fields" : ["desc"],
            "ids" : ["511111260"],
            "min_term_freq" : 1,
            "max_query_terms" : 25
        }
    }
}

Which returns

{
   "took": 16,
   "timed_out": false,
   "_shards": {
      "total": 3,
      "successful": 3,
      "failed": 0
   },
   "hits": {
      "total": 53,
      "max_score": 3.2860293,
      "hits": [ 
     ....

Which is fine but I need to specify additional constraint over other field 
of the underlying document which works separately fine:

POST /h/B/_search
{
    "query":{
               "bool" : {
            "must" : {
                "match" : { "Kind" : "Pen" }
            }
        }
    }
}

I would love to combine those two to one, as the query should state: "Find 
a similar items to items labeled with Pen". I tried following with nested 
query but that gives me some error back:

POST /h/B/_search
{
    "query":{
        "more_like_this" : {
            "fields" : ["desc"],
            "ids" : ["511111260"],
            "min_term_freq" : 1,
            "max_query_terms" : 25
        },
            "nested":{
                "query":{
                    "bool" : {
                        "must" : {
                            "match" : { "Kind" : "Pen" }
                        }
                    }
                }
            }
    }
}

I tried several variant for combining those two search criteria but so far 
with no luck. If someone more experienced could provide some hint that 
would be really appreciated.

Thanks for helping me 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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/7bfb66b3-bd88-4fb9-8514-a80d61671f8d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to