How to merge SearchHitField and HighlightField


(Weiwei Wang) #1

I noticed the search response seperate SearchHitField and
HighlightField.

I have a field like "phone":
[{"number":"18711341344","op":"ChinaMobile"},
{"number":"139112314313","op":"ChinaMobile"}, when do highlighting for
phone.number, the result return is something like that

{
"took" : 7,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 0.29792547,
"hits" : [ {
"_index" : "pim",
"_type" : "contact",
"_id" : "8a92e6e5335f724b013361dacd1225bd",
"_score" : 0.29792547,
"fields" : {
"id" : "8a92e6e5335f724b013361dacd1225bd",
"phone" : [ {
"op" : "China Mobile",
"number" : "13681011893"
}, {
"op" : "China Mobile",
"number" : "13681011893"
}, {
"op" : "China Mobile",
"number" : "13681011893"
} ],
},
"highlight" : {
"phone.number" : [ "1368101189<span class="hl">136810</
span>3", "1368101189<span class="hl">1368103",
"1368101189<span class="hl">1368103" ]
}
}]
}
}

so how to merge the result for use is a problem, what i would like is
the SearchHitField already include the highlight result.

Besides, there is a bug for highlighter, if i set mapping for
phone.number with "term_vector":"with_positions_offsets", then the
highlight result will concatenate the three numbers to only one
highlighted string, which is also mentioned in

when i changed the term_vector to no, the highlighter works fine.


(system) #2