We have a locale filter, so ES returns the documents which have description
in locale acceptable by user and ordered by his preference e.g. en-gb,en,it
(similar to HTTP Accept-Language header without quality parameter). This
works fine and also searching by description dependent on locale.
On frontend we always use just one description per document, the one with
locale which is the most accurate to user's preference. This is done on
Java side. But what we need is to allow ordering by the descriptions field,
which is array in ES. I know that it isn't possible to order by array
fields as it doesn't make sense. Is there any possibility to filter out
unnecessary descriptions and order by description when we know which
description will be used based on user's language preference?
The last possible solution we would like to avoid is to read all matched
documents and order it on Java side, but we use pagination, and after that
we would read all documents, order them, and return only those which are on
the requested page.
We have a locale filter, so ES returns the documents which have
description in locale acceptable by user and ordered by his preference e.g.
en-gb,en,it (similar to HTTP Accept-Language header without quality
parameter). This works fine and also searching by description dependent on
locale.
On frontend we always use just one description per document, the one with
locale which is the most accurate to user's preference. This is done on
Java side. But what we need is to allow ordering by the descriptions field,
which is array in ES. I know that it isn't possible to order by array
fields as it doesn't make sense. Is there any possibility to filter out
unnecessary descriptions and order by description when we know which
description will be used based on user's language preference?
The last possible solution we would like to avoid is to read all matched
documents and order it on Java side, but we use pagination, and after that
we would read all documents, order them, and return only those which are on
the requested page.
Thank you for that, but the problem is more complicated. I've resolved it
by using ScriptSortBuilder where I can take the most relevant description
according to user's language preference and then use the description for
ordering.
On Wednesday, March 21, 2012 4:44:12 PM UTC+1, Igor Motov wrote:
Wouldn't it simplify things if you changed your sample document into
something like this:
We have a locale filter, so ES returns the documents which have
description in locale acceptable by user and ordered by his preference e.g.
en-gb,en,it (similar to HTTP Accept-Language header without quality
parameter). This works fine and also searching by description dependent on
locale.
On frontend we always use just one description per document, the one with
locale which is the most accurate to user's preference. This is done on
Java side. But what we need is to allow ordering by the descriptions field,
which is array in ES. I know that it isn't possible to order by array
fields as it doesn't make sense. Is there any possibility to filter out
unnecessary descriptions and order by description when we know which
description will be used based on user's language preference?
The last possible solution we would like to avoid is to read all matched
documents and order it on Java side, but we use pagination, and after that
we would read all documents, order them, and return only those which are on
the requested page.
On Thursday, March 22, 2012 1:32:44 PM UTC+1, Ján Paľko wrote:
Thank you for that, but the problem is more complicated. I've resolved it
by using ScriptSortBuilder where I can take the most relevant description
according to user's language preference and then use the description for
ordering.
On Wednesday, March 21, 2012 4:44:12 PM UTC+1, Igor Motov wrote:
Wouldn't it simplify things if you changed your sample document into
something like this:
We have a locale filter, so ES returns the documents which have
description in locale acceptable by user and ordered by his preference e.g.
en-gb,en,it (similar to HTTP Accept-Language header without quality
parameter). This works fine and also searching by description dependent on
locale.
On frontend we always use just one description per document, the one
with locale which is the most accurate to user's preference. This is done
on Java side. But what we need is to allow ordering by the descriptions
field, which is array in ES. I know that it isn't possible to order by
array fields as it doesn't make sense. Is there any possibility to filter
out unnecessary descriptions and order by description when we know which
description will be used based on user's language preference?
The last possible solution we would like to avoid is to read all matched
documents and order it on Java side, but we use pagination, and after that
we would read all documents, order them, and return only those which are on
the requested page.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.