Sorting by numeric value has an exception "(expected=NUMERIC). Use UninvertingReader or index with docvalues"

Description

If I use a field definition where the value is of type "Double". When I try to sort through this field, I get the "(expected=NUMERIC). Use UninvertingReader or index with docvalues" exception.

{{@Indexed
public class Assortment
@Id
@DocumentId
@Column(name = "Id", length = 128)
private String id;
........
@OneToMany(mappedBy = "assortment", orphanRemoval = true, fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@IndexedEmbedded(includeEmbeddedObjectId = true)
private List<AssortmentPrice> prices = new ArrayList<>();
.......
}

public class AssortmentPrice implements Serializable {

@Id
@DocumentId
@Column(name = "Id", length = 128)
private String id;
.........
@Column(name = "BruttoPrice")
@SortableField(forField = "bruttoPrice_sort")
@NumericField(forField = "bruttoPrice_sort", precisionStep = 2)
@Field(name = "bruttoPrice_sort", analyze = Analyze.NO)
private Double bruttoPrice;
.......
}

Sort sort = new Sort(new SortField("prices.bruttoPrice_sort", SortField.Type.DOUBLE));
fullTextQuery.setSort(sort);

}}

Attachments

2

duplicates

Activity

Show:

Yoann Rodière March 5, 2020 at 4:01 PM

Since the solution basically amounts to implementing sorts for multi-valued fields, I'll close this ticket in favor of HSEARCH-3103.

Waldemar Kłaczyński February 27, 2020 at 8:36 PM

The sorting problem is solved in the patch. But it will still solve the aggregation problem. I think that it would be possible to pick it up completely.

Yoann Rodière February 27, 2020 at 2:40 PM

> As suggested, I put the proposed solution on hibernate-search for git. I have improved the formatting to Eclipse.

Thank you. Can you send an actual pull request, please? On top of being legal proof that you actually allow us to use your code, this will make reviewing and improving the patch much easier.

You just need to press the "New pull request" button next to the branch name on this page: https://github.com/wklaczynski/hibernate-search/tree/multivalues-problem-HSEARCH-3839

You can find a guide to sending pull requests in the CONTRIBUTING.md file.

Waldemar Kłaczyński February 27, 2020 at 1:55 PM

As suggested, I put the proposed solution on hibernate-search for git. I have improved the formatting to Eclipse.

As for other aggregation and search problems, I also have to solve this. Unfortunately, I can't wait, problems are critical for me, I can't develop my assumptions for my project without it. So I can't wait. I will try to find a solution to the problems. Of course, I will propose the solution as an offer.

 

 

Yoann Rodière February 26, 2020 at 4:40 PM

> This is also a critical problem, I will try to solve it.

If the problem is just that too many values are considered during the sort, I'd recommend that you submit a PR first and that we create a follow-up ticket to address this as a separate issue.

From what I understand, Elasticsearch has a dedicated feature for that, and this will likely require extensive testing if we re-implement it in Hibernate Search. Let's address one problem at a time?

Duplicate

Details

Assignee

Reporter

Components

Sprint

Affects versions

Priority

Created February 24, 2020 at 12:37 AM
Updated March 5, 2020 at 4:01 PM
Resolved March 5, 2020 at 4:01 PM