Highlight 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


(Shay Banon) #2

If you want to highlight only what you typed, do it on the client side.
On Tuesday, March 1, 2011 at 7:53 PM, alheim wrote:

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


(system) #3