Hi,
I can't get highlighting to work with the Groovy API. Below are the
request and response for both the REST API and the Groovy API. The
REST API works fine.
REST REQUEST:
curl -XGET 'http://localhost:9200/twitter/tweet/_search' -d '
{
"highlight" : {
"fields" : {
"_all" : {}
}
},
query : {
term: {
"user" : "kimchy"
}
}
}
'
REST RESPONSE:
"took":3,"_shards":{"total":5,"successful":5,"failed":0},"hits":
{"total":1,"max_score":0.30685282,"hits":
[{"_index":"twitter","_type":"tweet","_id":"1","_score":0.30685282,
"_source" :
{
"user" : "kimchy",
"postDate" : "2009-11-15T14:12:12",
"message" : "trying out Elastic Search"
}
,"highlight":{"_all":["kimchy 2009-11-15T14:12:12 trying
out Elastic Search "]}}]}}
GROOVY REQUEST:
def search = esClient.search {
indices "twitter"
source {
query {
query_string (
query : "kimchy"
)
}
highlight : {
fields : {
_all : {}
}
}
}
}
def results = search.response.hits.each { SearchHit hit ->
println hit.dump()
}
GROOVY RESPONSE:
<org.elasticsearch.search.internal.InternalSearchHit@46decb41 docId=0
score=0.06780553 id=1 type=tweet
source=[10, 123, 10, 32, 32, 32, 32, 34, 117, 115, 101, 114, 34, 32,
58, 32, 34, 107, 105, 109, 99, 104, 121, 34, 44, 10, 32, 32, 32, 32,
34,
112, 111, 115, 116, 68, 97, 116, 101, 34, 32, 58, 32, 34, 50, 48,
48, 57, 45, 49, 49, 45, 49, 53, 84, 49, 52, 58, 49, 50, 58, 49, 50,
34, 44,
10, 32, 32, 32, 32, 34, 109, 101, 115, 115, 97, 103, 101, 34, 32,
58,
32, 34, 116, 114, 121, 105, 110, 103, 32, 111, 117, 116, 32, 69,
108, 97, 115, 116, 105, 99, 32, 83, 101, 97, 114, 99, 104, 34, 10,
125, 10]
fields=[:] highlightFields=[:]
sortValues=[] matchedFilters=[] explanation=null
shard=[gCwC-CZSTpmkoshfcTidnQ][twitter][2] sourceAsMap=null>
Here's the mapping I'm using:
curl -XPUT 'http://localhost:9200/twitter/tweet/_mapping' -d '
{
"tweet" : {
_all : {type: "string", "store" : "yes", "term_vector" :
"with_positions_offsets"}
}
}
}
'
Thanks.
Mike