Highlighting part of a term


(Alexandre Heimburger) #1

Hi,

I'm still working on a fast highlighted autocomplete.

Imagine that I query 'andr'

'Alexandre' and 'Andre' are matching but both terms are fully highlighted. I
would like to hightlight only the letter I typed.

Here is my mapping :

{
2 "usr" : {
3 "properties" : {
4 "title" : {
5 "type" : "string",
6 "term_vector" : "with_positions_offsets"

7 }
8 }
9 }
10 }
11 }

Here is the query :

array('query'=>array('bool'=> array(
'must' =>
array("query_string"=>array('default_field'=>"title",
'default_operator'=>'AND', 'query'=>"$str")),
'minimum_number_should_match'=> 1,
'boost' => 1.0
)
),
'highlight' =>
array('fields'=>array('title'=>array('fragment_size'=>150,'number_of_fragments'=>3)))
);

Any clue ?

Thanks


(Ilia Valchenko) #2

I think you could try to use nGram analyzer and custom tokenizer. I found answer on stackoverflow. I hope it will help you.


(system) #3