Reputation: 827
I am using Solr as a search engine on my site.
Is there any way to get only part of the result content with the search keys distinguished?
{
"id": "http://test.com",
"url": "http://test.com",
"content": [
"a lot of content ...."
],
"score": 0.0105027985
}
Upvotes: 0
Views: 56
Reputation: 22555
What you need to use is Highlighting.
Solr provides a collection of highlighting utilities which can be called by various Request Handlers to include "highlighted" matches in field values. These highlighting utilities may be used with the DisMax, Extended DisMax, or standard query parsers.
Check out the following references for setting up Highlighting:
These resources should help you setup your search requests to highlight the search terms and return them in an appropriate sized snippet.
Upvotes: 1
Reputation: 343
If you need only the fields (the "search keys") field1 and field2, you will have to add to you request URI the following param :
fl=field1,field2
Exemple : http://wiki.apache.org/solr/CommonQueryParameters#fl
Upvotes: 0