Skip to content

Instantly share code, notes, and snippets.

@imotov
Created August 7, 2012 00:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imotov/3279879 to your computer and use it in GitHub Desktop.
Save imotov/3279879 to your computer and use it in GitHub Desktop.
Solr 3.6.1 highlighting
<add><doc>
<field name="id">1</field>
<field name="message">foo and bar and something else</field>
</doc></add>
http://localhost:8983/solr/select?indent=on&version=2.2&q=message%3A%22foo+and+bar%22+message_nopos%3A%22foo+and+bar%22+message_novec%3A%22foo+and+bar%22&fq=&start=0&rows=10&fl=*%2Cscore&wt=&explainOther=&hl=on&hl.fl=message%2Cmessage_nopos%2Cmessage_novec&hl.useFastVectorHighlighter=true
http://localhost:8983/solr/select?indent=on&version=2.2&q=message%3A%22foo+and+bar%22+message_nopos%3A%22foo+and+bar%22+message_novec%3A%22foo+and+bar%22&fq=&start=0&rows=10&fl=*%2Cscore&wt=&explainOther=&hl=on&hl.fl=message%2Cmessage_nopos%2Cmessage_novec
<?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">15853</int>
<lst name="params">
<str name="explainOther"/>
<str name="indent">on</str>
<str name="hl.fl">message,message_nopos,message_novec</str>
<str name="wt"/>
<str name="hl">on</str>
<str name="version">2.2</str>
<str name="rows">10</str>
<str name="fl">*,score</str>
<str name="hl.useFastVectorHighlighter">true</str>
<str name="start">0</str>
<str name="q">message:"foo and bar" message_nopos:"foo and bar" message_novec:"foo and bar"</str>
<str name="fq"/>
</lst>
</lst>
<result name="response" numFound="1" start="0" maxScore="0.53148466">
<doc>
<float name="score">0.53148466</float>
<str name="id">1</str>
<str name="message">foo and bar and something else</str>
<str name="message_nopos">foo and bar and something else</str>
<str name="message_novec">foo and bar and something else</str>
</doc>
</result>
<lst name="highlighting">
<lst name="1">
<arr name="message_nopos">
<str>&lt;em&gt;foo and bar&lt;/em&gt; and something else</str>
</arr>
<arr name="message_novec">
<str>&lt;em&gt;foo&lt;/em&gt; and &lt;em&gt;bar&lt;/em&gt; and something else</str>
</arr>
</lst>
</lst>
</response>
<?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">3</int>
<lst name="params">
<str name="explainOther"/>
<str name="fl">*,score</str>
<str name="indent">on</str>
<str name="start">0</str>
<str name="q">message:"foo and bar" message_nopos:"foo and bar" message_novec:"foo and bar"</str>
<str name="hl.fl">message,message_nopos,message_novec</str>
<str name="wt"/>
<str name="fq"/>
<str name="hl">on</str>
<str name="version">2.2</str>
<str name="rows">10</str>
</lst>
</lst>
<result name="response" numFound="1" start="0" maxScore="0.53148466">
<doc>
<float name="score">0.53148466</float>
<str name="id">1</str>
<str name="message">foo and bar and something else</str>
<str name="message_nopos">foo and bar and something else</str>
<str name="message_novec">foo and bar and something else</str>
</doc>
</result>
<lst name="highlighting">
<lst name="1">
<arr name="message">
<str>&lt;em&gt;foo&lt;/em&gt; and &lt;em&gt;bar&lt;/em&gt; and something else</str>
</arr>
<arr name="message_nopos">
<str>&lt;em&gt;foo&lt;/em&gt; and &lt;em&gt;bar&lt;/em&gt; and something else</str>
</arr>
<arr name="message_novec">
<str>&lt;em&gt;foo&lt;/em&gt; and &lt;em&gt;bar&lt;/em&gt; and something else</str>
</arr>
</lst>
</lst>
</response>
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<schema name="example" version="1.5">
<types>
<!-- The StrField type is not analyzed, but indexed/stored verbatim. -->
<fieldType name="string" class="solr.StrField" sortMissingLast="true"/>
<fieldType name="my_text_general" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="lang/stopwords_en.txt" enablePositionIncrements="true"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="lang/stopwords_en.txt" enablePositionIncrements="true"/>
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
<fieldType name="my_text_general_nopos" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="lang/stopwords_en.txt" enablePositionIncrements="false"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="lang/stopwords_en.txt" enablePositionIncrements="false"/>
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
</types>
<fields>
<field name="id" type="string" indexed="true" stored="true" required="true"/>
<field name="message" type="my_text_general" indexed="true" stored="true" required="true" termVectors="true" termPositions="true" termOffsets="true"/>
<field name="message_nopos" type="my_text_general_nopos" indexed="true" stored="true" required="true" termVectors="true" termPositions="true" termOffsets="true"/>
<field name="message_novec" type="my_text_general" indexed="true" stored="true" required="true"/>
</fields>
<uniqueKey>id</uniqueKey>
<copyField source="message" dest="message_nopos"/>
<copyField source="message" dest="message_novec"/>
</schema>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment