带有 LIKE 子句的 Solr 查询 [英] Solr Query with LIKE Clause
问题描述
我正在使用 Solr,我想知道查询中是否可以包含 LIKE 子句.例如,我想知道所有标题中带有纽约"的组织.在 SQL 中,这会写成 Name LIKE 'New York%'.
I'm working with Solr and I'd like to know if it is possible to have a LIKE clause in the query. For example, I want to know all organizations with "New York" in the title. In SQL, this would be written like Name LIKE 'New York%'.
我的问题 - 你如何在 Solr 中编写 LIKE 查询?
My question - how do you write a LIKE query in Solr?
我正在使用 SolrNet 库,如果这有什么不同的话.
I'm using the SolrNet library, if that makes a difference.
推荐答案
您只需搜索纽约",但首先您需要正确配置字段的分析器.例如,您可能希望从 默认 Solr 架构.此字段类型将对空格和其他常用单词分隔符进行标记,然后应用停用词过滤器,然后将术语小写以使搜索不区分大小写.
You just search for "New York", but first you need to properly configure your field's analyzer. For example you might want to start with a field type like text_general
as defined in the default Solr schema. This field type will tokenize on whitespace and other common word separators, then apply a filter of stopwords, then lowercase the terms in order to make searches case-insensitive.
有关Solr wiki 中的分析器的更多信息.
这篇关于带有 LIKE 子句的 Solr 查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!