How do I group search results returned by Lucene by fields (similar to SQL Server's)?
相关问题
- JCR-SQL - contains function doesn't escape spe
- Match lucene entire field exact value
- How to rank documents using tfidf similairty in lu
- Lucene Query on a DateField indexed by Solr
- How to token a word which combined by two words wi
相关文章
- Solr - _version_ field must exist in schema and be
- CakePHP with Lucene
- Apache Lucene doesn't filter stop words despit
- Sort by date in Solr/Lucene performance problems
- What Solr tokenizer and filters can I use for a st
- Solr: How to dynamically elevate limited number of
- Finding a single fields terms with Lucene (PyLucen
- how to add custom stop words using lucene in java
It's not clear whether you want a true SQL-like "GROUP BY" behavior, or merely an "ORDER BY" behavior. There's nothing like aggregation functions in Lucene, so "GROUP BY" would have to implemented in your application, on top of Lucene.
However, sorting by fields is fairly easy. Make sure the desired field is indexed, and create a
org.apache.lucene.search.Sort
object to be passed as part of the search criteria; most search methods have an overload that accepts aSort
instance.If you were to implement your own "GROUP BY" logic, having the results "ORDERED BY" the correct fields is a helpful first step.
Lucene has some suplimentary libraries, one being what you need: Grouping
You can't group by function query values nor by arbitrary queries(like Solr does), but you can by single-valued field.
Something similar(faceted search) will be implemented in Lucene 4.0
https://issues.apache.org/jira/browse/LUCENE-1421
it appears that you cant. there is possibly a workaround though: theres a thread here which outlines how someone else has done it : here
Lucene 3.4 now supports faceted search. At indexing you specify something supplementary and at search time you search by query and by groups.
for next 3 docs, that you index with these groups
you can search only for the first param: monday, and get value:3, or you can drill down and search for monday/1pm and get value:2 or set depth of search 3 and get
here's the source sample :
But most of all readfaceted search