开发者

SOLR How to return only limited matched content

ok guys, say in my Schema I have 4 fields:

<field name="SiteIdentifier" type="string" indexed="true" stored="true" required="true"/>
<field name="Title" type="text" indexed="true" stored="true"/>
<field name="Content" type="text" indexed="true" stored="true"/>
<field name="URL" type="text" indexed="true" stored="true"/>

Is there some kind of built in FieldType in SOLR where I can return only a limited amount of text from one of my fields above.

So, say in my Index the field "Content" has 500 characters in it. I search for the word "subscribe". Say the word "subscribe" appears twice or more in a particular "Content" field.

Now, in this case, I only want to return, no matter what, 100 characters form the content field.

First of all, is this possible and simple, by just using a FieldType I'm not aware of?

if so, can also specify that it returns the 100 characters that contain AT LEAST ONE occurrence of the search te开发者_Python百科rm?

cool, thank you!


I think you're looking for a feature called "hit highlighting", which allows you to highlight text that matches the query.

See the docs and sample1, sample2.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜