Highlight text search by elasticsearch

Hi,

I want to highlight the text in my response which I am enter in my elastic
search.

e.g.-

i am writing this http://localhost:9200/productindex/_search?q=armani in
URL

and in response i got the json object which contains armani. what I want
to change color of armani to yellow or orange in the response text so that
it is easy to see which text i am searching. Is there any way to do this

thanks

--
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/658eb895-df85-4a19-8c36-f3936beba4b6%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

What tool are you using?
A browser (or curl) should not add color to JSON docs...

But there is an highlighting feature in Elasticsearch which will produce something you can display.
See http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-highlighting.html

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 6 mars 2014 à 06:50, robin thakur thakurrobin7@gmail.com a écrit :

Hi,

I want to highlight the text in my response which I am enter in my elastic search.

e.g.-

i am writing this http://localhost:9200/productindex/_search?q=armani in URL

and in response i got the json object which contains armani. what I want to change color of armani to yellow or orange in the response text so that it is easy to see which text i am searching. Is there any way to do this

thanks

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/658eb895-df85-4a19-8c36-f3936beba4b6%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
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/07EFA6D8-D576-4618-BA75-A02BEC66E8EA%40pilato.fr.
For more options, visit https://groups.google.com/groups/opt_out.

I am using browser simply hit the URL, using ajax call this URL
http://localhost:9200/productindex/_search?q=armani
what i want all the armani word are highlighted on my webpage, no need for
color change if not possible.
Is there any parameter in URI like
q for query(http://localhost:9200/productindex/_search?q=armani),
size for size of hits(
http://localhost:9200/productindex/_search?size=2&q=armanihttp://localhost:9200/productindex/_search?q=armani),

I want same for highlight like (
http://localhost:9200/productindex/_search?q=armani&highlight=armani)

--
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/6ba8a8df-cf96-4040-83d2-49ea117bb9d8%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

I don't know how to tell you that a browser by its own does not render any json document.

Elasticsearch does not have graphical interface. It's a "server". You can have a look at Kibana if you want that.

If you want that elasticsearch returns you highlight fragments, you need to use highlight feature and render the result in your application.

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 6 mars 2014 à 08:19, robin thakur thakurrobin7@gmail.com a écrit :

I am using browser simply hit the URL, using ajax call this URL http://localhost:9200/productindex/_search?q=armani
what i want all the armani word are highlighted on my webpage, no need for color change if not possible.
Is there any parameter in URI like
q for query(http://localhost:9200/productindex/_search?q=armani),
size for size of hits(http://localhost:9200/productindex/_search?size=2&q=armani),

I want same for highlight like (http://localhost:9200/productindex/_search?q=armani&highlight=armani)

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/6ba8a8df-cf96-4040-83d2-49ea117bb9d8%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
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/433405B7-A402-41D9-B546-EF6179C55964%40pilato.fr.
For more options, visit https://groups.google.com/groups/opt_out.

can you explain this with some example , so its easy to me to understand

--
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/019b2061-ed14-4f9f-8faf-b89d845b82f6%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

It's hard to explain without any exact question.
Could you describe what you did not understand in what I wrote before?

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr

Le 6 mars 2014 à 09:08:20, robin thakur (thakurrobin7@gmail.com) a écrit:

can you explain this with some example , so its easy to me to understand

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/019b2061-ed14-4f9f-8faf-b89d845b82f6%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
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/etPan.53182ea2.257130a3.7bfa%40MacBook-Air-de-David.local.
For more options, visit https://groups.google.com/groups/opt_out.

ok, I will try to explain
I have this URL http://localhost:9200/productindex/_search?q=armani on
going to this I am getting this

{
"took": 6,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 0.112474404,
"hits": [
{
"description": "

Armani Code pour Femme 2010

",
"name": "Armani Code Femme EDP 75ml W",
}
}
}

Is it possible to get this json having
"description": "

*Armani *Code pour Femme 2010

",
"name": "Armani Code Femme EDP 75ml W",

i am also using
{
"highlight" : {
"fields" : {
"content" : {"force_source" : true}
}
}
}
in body, but it is not working.

thanks

--
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/08f279d1-88cd-4133-808c-833af301a5c8%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Yes it is possible if you apply exactly what is written in the guide: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-highlighting.html

What query did you run? What is not working?

If you could gist a full example of what you are doing it could help a lot and save some time: See http://www.elasticsearch.org/help/

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr

Le 6 mars 2014 à 09:32:09, robin thakur (thakurrobin7@gmail.com) a écrit:

ok, I will try to explain
I have this URL http://localhost:9200/productindex/_search?q=armani on going to this I am getting this

{
"took": 6,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 0.112474404,
"hits": [
{
"description": "

Armani Code pour Femme 2010

",
"name": "Armani Code Femme EDP 75ml W",
}
}
}

Is it possible to get this json having
"description": "

Armani Code pour Femme 2010

",
"name": "Armani Code Femme EDP 75ml W",

i am also using
{
"highlight" : {
"fields" : {
"content" : {"force_source" : true}
}
}
}
in body, but it is not working.

thanks

--
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/08f279d1-88cd-4133-808c-833af301a5c8%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
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/etPan.5318373d.836c40e.7bfa%40MacBook-Air-de-David.local.
For more options, visit https://groups.google.com/groups/opt_out.

I run this

curl -XGET 'http://127.0.0.1:9200/productindex/_search?q='+productName -d
{
"highlight" : {
"fields" : "product.name"
}
};

--
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/3be879e4-4011-4111-ad02-04f91ed14f5c%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

You can not mix both syntax (as a http parameter and as a body).

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr

Le 6 mars 2014 à 10:18:58, robin thakur (thakurrobin7@gmail.com) a écrit:

I run this

curl -XGET 'http://127.0.0.1:9200/productindex/_search?q='+productName -d
{
"highlight" : {
"fields" : "product.name"
}
};

--
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/3be879e4-4011-4111-ad02-04f91ed14f5c%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
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/etPan.53183e0d.2d517796.7bfa%40MacBook-Air-de-David.local.
For more options, visit https://groups.google.com/groups/opt_out.

I don't want anything in body so how do I put highlight parameter in http
url

--
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/23fcb776-e8ed-4f0f-a442-e415e6f33952%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Have a look at: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-body.html

The rest of the search request should be passed within the body itself. The body content can also be passed as a REST parameter named source.

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr

Le 6 mars 2014 à 10:30:21, robin thakur (thakurrobin7@gmail.com) a écrit:

I don't want anything in body so how do I put highlight parameter in http url

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/23fcb776-e8ed-4f0f-a442-e415e6f33952%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
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/etPan.5318431f.725a06fb.7bfa%40MacBook-Air-de-David.local.
For more options, visit https://groups.google.com/groups/opt_out.

hi david,

I think you don't understand what I want,My simple query is how we put
highlight parameter in URL.The link you provide me is not much explainatory
to about what to do.
I am still searching for this.

--
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/ede0acd5-a163-40bd-ad8f-65c9180f57fc%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

The link I provided tells you that if you don't want to use HTTP body, you can put your JSON QueryDSL as an HTTP parameter under source.

Something like: http://localhost:9200/_search?source=XXXXXX

Where XXXXX is your json document (QueryDSL that is)

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr

Le 6 mars 2014 à 11:01:17, robin thakur (thakurrobin7@gmail.com) a écrit:

hi david,

I think you don't understand what I want,My simple query is how we put highlight parameter in URL.The link you provide me is not much explainatory to about what to do.
I am still searching for this.

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/ede0acd5-a163-40bd-ad8f-65c9180f57fc%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
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/etPan.531848d4.1ba026fa.7bfa%40MacBook-Air-de-David.local.
For more options, visit https://groups.google.com/groups/opt_out.