Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do grouping in Lucene search results?

Tags:

lucene

How do I group search results returned by Lucene by fields (similar to SQL Server's)?

like image 482
user43478 Avatar asked Dec 05 '08 05:12

user43478


People also ask

How do you search in Lucene?

Lucene supports single and multiple character wildcard searches within single terms (not within phrase queries). To perform a single character wildcard search use the "?" symbol. To perform a multiple character wildcard search use the "*" symbol. You can also use the wildcard searches in the middle of a term.

How does Lucene index search work?

Simply put, Lucene uses an “inverted indexing” of data – instead of mapping pages to keywords, it maps keywords to pages just like a glossary at the end of any book. This allows for faster search responses, as it searches through an index, instead of searching through text directly.

How does Lucene sort work?

The default search implementation of Apache Lucene returns results sorted by score (the most relevant result first), then by id (the oldest result first). This behavior can be customized at query time with an additionnal Sort parameter . The Sort parameter specifies the fields or properties used for sorting.


2 Answers

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

doc1: monday, 1pm,  3min    
doc2: monday, 1pm,  4min    
doc3: monday, 2pm,  3min

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

monday :3
monday/1pm :2
monday/1pm/3min :1
monday/1pm/4min :1
monday/2pm :1
monday/2pm/3min :1

here's the source sample :

But most of all readfaceted search

like image 110
mihaicc Avatar answered Sep 23 '22 03:09

mihaicc


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

like image 38
gcrain Avatar answered Sep 24 '22 03:09

gcrain