Foros de discusión

Lucene: Get distinct values for a group of fields from a list of records

thumbnail
Prakash Khanchandani, modificado hace 8 años.

Lucene: Get distinct values for a group of fields from a list of records

Expert Mensajes: 329 Fecha de incorporación: 10/02/11 Mensajes recientes
We are using Liferay (6.2 CE GA4) with Lucene to perform search on custom assets. Currently we can retrieve the proper hits and the full documents.

We want to return a unique combination of certain fields for our custom asset.

To make it more clear, we want to do something similar to the following SQL query but using Lucene in Liferay:

SELECT DISTINCT
    field01, field02, field03 
FROM
    FieldsTable
WHERE
    someOtherField04 LIKE "%test%";
ORDER BY
    field01 ASC, field02 ASC, field03 ASC;


How we are doing it currently

Currently we are manually fetching field values by iterating through all the documents and then filtering the duplicate combination. This process takes time when there are more than 5k records to process on each request. And the distinct field values would mostly be a few hundred records.

Any help is much appreciated.

Thanks

PS: Also posted on stackoverflow: http://stackoverflow.com/q/30982986/468763
thumbnail
Tobias Liefke, modificado hace 8 años.

RE: Lucene: Get distinct values for a group of fields from a list of record

Junior Member Mensajes: 78 Fecha de incorporación: 23/11/12 Mensajes recientes
You can find my answer in stackoverflow.