Kamran Ali
Kamran Ali

Reputation: 5954

How to use aggregate function in lucene query string

I'm using apache lucene for indexing and searching in my application. Everything is working fine and now i've to integrate reporting and for that i need aggregate values. I've been stuck and couldn't find a way to use aggregate function in lucene search string like we can use them in HQL very easily!

Any hints or way around to use aggregate function in lucene search string?

Upvotes: 0

Views: 7510

Answers (2)

jpountz
jpountz

Reputation: 9964

Unlike HQL (and SQL), Lucene query syntax does not let you retrieve aggregates. However, you might be interested in a somewhat similar feature called faceting which lets you retrieve category counts for your query .

Upvotes: 1

Liam
Liam

Reputation: 2837

One way to do it is using catchall field, containing all other searchable text fields (implemented via copyField in the schema)

defaultSearchField to search within different aggregate fields

If you want aggregation in query then combine your data using the data-import schema ,put it in a field and use that field in the defaultSearchField

Upvotes: 0

Related Questions