如何在lucern solr中搜索全部/通配符

时间:2021-07-09 04:36:18

I'm using RoR + acts_as_solr to query a Solr database.

我正在使用RoR + acts_as_solr来查询Solr数据库。

I'm used to using "*" to select all, thanks to MySQL, but that command fires an exception in Solr. Are they other wildcards I can use? Suggestions? Thanks!

我习惯使用“*”来选择所有,这要归功于MySQL,但是该命令会在Solr中触发异常。它们是我可以使用的其他通配符吗?建议?谢谢!

4 个解决方案

#1


You can't query for "all" in lucene. The typical way to do it is to add a field with the same value for all documents and query for that value.

你不能在lucene中查询“all”。执行此操作的典型方法是为所有文档添加具有相同值的字段并查询该值。

#2


In Solr you can get all documents by querying *:* (except for pagination, that's another topic)

在Solr中,您可以通过查询*:*来获取所有文档(除了分页,这是另一个主题)

#3


I prefer [* TO *] when I have used acts_as_solr. *:* seemed to perform much slower.

我使用acts_as_solr时更喜欢[* TO *]。 *:*似乎表现得慢得多。

#4


It depends what you need to select all data for. By emulating a select * I assume you want all fields back from the document; this would happen naturally from your search terms as you just limit the documents returned.

这取决于您需要选择的所有数据。通过模拟select *我假设您希望从文档中返回所有字段;这会自然地从您的搜索字词中发生,因为您只是限制返回的文档。

select * from index where id = 'Burrito'

would be the same as just searching for

就像搜索一样

id:Burrito

You would not have to do

你不必这样做

*:* AND id:Burrito

If you want to see all the documents then use : as already suggested.

如果您想查看所有文档,请使用:已经建议。

#1


You can't query for "all" in lucene. The typical way to do it is to add a field with the same value for all documents and query for that value.

你不能在lucene中查询“all”。执行此操作的典型方法是为所有文档添加具有相同值的字段并查询该值。

#2


In Solr you can get all documents by querying *:* (except for pagination, that's another topic)

在Solr中,您可以通过查询*:*来获取所有文档(除了分页,这是另一个主题)

#3


I prefer [* TO *] when I have used acts_as_solr. *:* seemed to perform much slower.

我使用acts_as_solr时更喜欢[* TO *]。 *:*似乎表现得慢得多。

#4


It depends what you need to select all data for. By emulating a select * I assume you want all fields back from the document; this would happen naturally from your search terms as you just limit the documents returned.

这取决于您需要选择的所有数据。通过模拟select *我假设您希望从文档中返回所有字段;这会自然地从您的搜索字词中发生,因为您只是限制返回的文档。

select * from index where id = 'Burrito'

would be the same as just searching for

就像搜索一样

id:Burrito

You would not have to do

你不必这样做

*:* AND id:Burrito

If you want to see all the documents then use : as already suggested.

如果您想查看所有文档,请使用:已经建议。