English 中文(简体)
Solr: strip punctuation before index
原标题:

I am having a problem with striping punctuation from the solr index When the punctuation sign follow right after a word then this word is not indexed properly.

For example: if we index "hello, John", the asset won t be found by keyword "hello" while there will be no issue if we remove comma after word "hello".

Is there any FilterFactory that suppose to strip punctuation? Any ideas?

Thanks, Bogdan.

问题回答

You can use the solr.PatternReplaceFilterFactory to strip beginning and trailing punctuation with this:

<filter class="solr.PatternReplaceFilterFactory"
    pattern="^p{Punct}*(.*?)p{Punct}*$"
    replacement="$1"/>

And if you wanted to strip all punctuation at the beginning and end, except (for example) the dollar-sign in front of a word, you could use this:

<filter class="solr.PatternReplaceFilterFactory"
    pattern="^[p{Punct}&&[^$]]*(.*?)p{Punct}*$"
    replacement="$1"/>

This is done with the WordDelimiterFilterFactory. Set generateWordParts=1.

There is also the PatternTokenizerFactory that could be used, but I have never tried it.

Use PatternReplaceFilterFactory

<!-- remove punctuation -->
    <filter class="solr.PatternReplaceFilterFactory" pattern="^(p{Punct}*)(.*?)(p{Punct}*)$" replacement="$2"/>
    <filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.StandardFilterFactory"/>
    <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
  </analyzer>

...





相关问题
adding an index to sql server

I have a query that gets run often. its a dynmaic sql query because the sort by changes. SELECT userID, ROW_NUMBER(OVER created) as rownumber from users where divisionID = @divisionID and ...

Linq to SQL nvarchar problem

I have discovered a huge performance problem in Linq to SQL. When selecting from a table using strings, the parameters passed to sql server are always nvarchar, even when the sql table is a varchar. ...

TableView oval button for Index/counts

Can someone help me create an index/count button for a UITableView, like this one? iTunes http://img.skitch.com/20091107-nwyci84114dxg76wshqwgtauwn.preview.jpg Is there an Apple example, or other ...

Move or copy an entity to another kind

Is there a way to move an entity to another kind in appengine. Say you have a kind defines, and you want to keep a record of deleted entities of that kind. But you want to separate the storage of ...

热门标签