|
| 1 | +solr(14):solr.SynonymFilterFactory |
| 2 | +============================= |
| 3 | +https://wiki.apache.org/solr/AnalyzersTokenizersTokenFilters |
| 4 | + |
| 5 | +使用方式: |
| 6 | + |
| 7 | + <fieldtype name="syn" class="solr.TextField"> |
| 8 | + <analyzer> |
| 9 | + <tokenizer class="solr.WhitespaceTokenizerFactory"/> |
| 10 | + <filter class="solr.SynonymFilterFactory" synonyms="syn.txt" ignoreCase="true" expand="false"/> |
| 11 | + </analyzer> |
| 12 | + </fieldtype> |
| 13 | + |
| 14 | +配置文件syn.txt格式: |
| 15 | + |
| 16 | + # blank lines and lines starting with pound are comments. |
| 17 | + |
| 18 | + #Explicit mappings match any token sequence on the LHS of "=>" |
| 19 | + #and replace with all alternatives on the RHS. These types of mappings |
| 20 | + #ignore the expand parameter in the schema. |
| 21 | + #Examples: |
| 22 | + i-pod, i pod => ipod, |
| 23 | + sea biscuit, sea biscit => seabiscuit |
| 24 | + |
| 25 | + #Equivalent synonyms may be separated with commas and give |
| 26 | + #no explicit mapping. In this case the mapping behavior will |
| 27 | + #be taken from the expand parameter in the schema. This allows |
| 28 | + #the same synonym file to be used in different synonym handling strategies. |
| 29 | + #Examples: |
| 30 | + ipod, i-pod, i pod |
| 31 | + foozball , foosball |
| 32 | + universe , cosmos |
| 33 | + |
| 34 | + # If expand==true, "ipod, i-pod, i pod" is equivalent to the explicit mapping: |
| 35 | + ipod, i-pod, i pod => ipod, i-pod, i pod |
| 36 | + # If expand==false, "ipod, i-pod, i pod" is equivalent to the explicit mapping: |
| 37 | + ipod, i-pod, i pod => ipod |
| 38 | + |
| 39 | + #multiple synonym mapping entries are merged. |
| 40 | + foo => foo bar |
| 41 | + foo => baz |
| 42 | + #is equivalent to |
| 43 | + foo => foo bar, baz |
| 44 | + |
| 45 | +配置文件按行处理,空行和"#"开头的行都是注释,同义词有两种配置方式: |
| 46 | + |
| 47 | +1. 对于使用等式"=>"的行,expand参数会忽略掉,"=>"左边的词元将会被右边的词替换。如: |
| 48 | + |
| 49 | + i-pod, i pod => ipod, |
| 50 | + sea biscuit, sea biscit => seabiscuit |
| 51 | + 也就是说在搜索或者索引时,遇到i-pod或i pod时都将用ipod代替。 |
| 52 | +2. 同义词用逗号分隔,它没有显示的映射关系,它的映射策略取决于expand参数。例如: |
| 53 | + |
| 54 | + ipod, i-pod, i pod |
| 55 | + foozball , foosball |
| 56 | + universe , cosmos |
| 57 | + * 如果expand==true,那么它等效于: |
| 58 | + |
| 59 | + ipod, i-pod, i pod => ipod, i-pod, i pod |
| 60 | + 也就是说当你搜i-pod的时候,可以同时匹配ipod,i-pod,i pod,搜ipod的时候也是同理。 |
| 61 | + * 如果expand==false, 那么它等效于: |
| 62 | + ipod, i-pod, i pod => ipod |
| 63 | + 也即是说他只匹配改行的第一个词元。 |
| 64 | +另外多个同义词映射实体会被合并,如: |
| 65 | + foo => foo bar |
| 66 | + foo => baz |
| 67 | + foo => foo bar, baz |
| 68 | + |
| 69 | +3. ingoreCase:为true时忽略大小写,处理时都转换为小写 |
0 commit comments