0

I am running SOLR 3.6, and have documents that have tags indexed. When a user enters a search phrase, I'd like to be able to find documents with tags contained inside that query.

E.g, a user searching for "Any document that has boats tagged" would match a document that had "boats" as a tag.

I know you can do wildcard searching, but I need the wildcards applied to the solr field, not the search query.

The MySQL equivalent to this would be:

SELECT * FROM `documents` WHERE "Any document that has boats tagged" LIKE 'CONCAT('%', `document`, '%');

So I need a SOLR factory that will allow this type of query:

*document*:"Any document that has boats tagged"
4

1 回答 1

0

如果tagsSolr 中的字段在索引时间和查询时间都是带有 LowerCaseFilterFactory 的多值文本字段,那么您可以简单地发出以下查询:

q=tags:(Super fast boats)

(我在这里更改了您的示例。)这将为您提供首先具有所有 3 个标签(如果有)的文档,然后是具有 2 个标签(如果有)然后是 1 个标签的文档。

这是假设在您的 schema.xml 中您得到了<solrQueryParser defaultOperator="OR"/>. 如果您有 AND,则需要用ORlike 分隔单词:

q=tags:(any OR document OR that OR has OR boats OR tagged)

(您可能还想对标签和查询使用词干提取以匹配更多标签,但这是您需要试验和决定的事情。)

于 2013-03-29T05:13:29.233 回答