【发布时间】:2022-10-13 00:32:47
【问题描述】:
我正在尝试对 solr solr.TextField 字段运行正则表达式查询。这是否意味着该字段类型支持?
例如,我正在搜索 curl -g 'http://localhost:8983/solr/shard/select?rows=0&q=body:/hello/',它返回 > 0 个结果。
但是当我将它切换到curl -g 'http://localhost:8983/solr/shard/select?rows=0&q=body:/h[aeiou]llo/' 时,我得到 0 个结果?
<fieldType name="body_text" class="solr.TextField" positionIncrementGap="100" multiValued="false">
<analyzer>
<charFilter class="solr.PatternReplaceCharFilterFactory" pattern="[^a-zA-Z0-9_@-]+" replacement=" "/>
<tokenizer class="solr.WhitespaceTokenizerFactory" rule="java" />
<filter class="solr.LengthFilterFactory" min="2" max="45"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.StopFilterFactory" words="stopwords.txt" ignoreCase="true"/>
<filter class="solr.SynonymGraphFilterFactory" expand="true" ignoreCase="true" synonyms="synonyms.txt"/>
</analyzer>
</fieldType>
<field name="body" type="body_text" uninvertible="true" indexed="true" stored="false"/>
【问题讨论】:
-
h.llo是如何工作的?这会给你条目吗?即[]被转义并被视为表达式的一部分而不是字符组是否会成为问题? (使用 curl 时不应该是这种情况 - 但也许你的 shell 做了一些神奇的事情?检查 Solr 日志以了解实际收到的查询) -
@MatsLindh,没有
h.llo也不起作用。似乎一旦我添加任何类似正则表达式的特殊字符(编码或未编码),我就会返回零结果。响应显示格式正确的查询 -
您使用的是哪个 Solr 版本?
标签: solr