how to search all / wildcard in lucern solr

2019-07-13 10:50发布

问题:

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

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!

回答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.



回答2:

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



回答3:

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



回答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 * 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.