What's wrong with my match query in Java API?


(Daniel Guo) #1

I want to do a match query, and the query works fine in REST:

curl -XGET 'localhost:9200/search/video_search/_search?pretty' -d @query.
json

query.json:
{
"query": {
"match": {
"tvName": {
"query": "决战华岩寺",
"operator": "or",
"minimum_should_match": "2"
}
}
}
}

but I don't know how to do it in Java, my code below doesn't work:

MatchQueryBuilder queryBuilder = QueryBuilders.matchQuery("tvName", keyword)
.minimumShouldMatch("2")
.operator(MatchQueryBuilder.Operator.OR);

the exception is : Unexpected end of block of data.

Cloud anybody help? Thanks very much.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/86a21181-8007-4595-abc9-4b45f81b67a3%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Binh Ly-2) #2

Hmmm, not sure. I tired this and it worked for me:

  q = QueryBuilders.matchQuery("tvName", "决战华岩寺")
      .minimumShouldMatch("1")
      .operator(MatchQueryBuilder.Operator.OR);

Perhaps can you give a complete example of an index, 1 document, and the
actual full Java query to duplicate your problem?

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/723c084a-7549-4f3e-9109-77342bbc24bf%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #3