Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HSEARCH-2535 @Facet on container (Iterable, Array, ...) properties indexes the container's toString() #1273

Closed
wants to merge 4 commits into from

Conversation

yrodiere
Copy link
Member

@yrodiere yrodiere commented Jan 2, 2017

https://hibernate.atlassian.net/browse/HSEARCH-2535

I added code to support both collections of Strings and collections of numeric values, but only containers of Strings work right now, due to HSEARCH-1927. This one will have to be fixed in another PR.

I think it's safe to merge this PR during the CR period, because the previous behavior was clearly suboptimal:

  • it simply failed for multi-valued numeric fields, which it still will unless you only have arrays/collections/maps with one element
  • and more importantly it used to index the result of calling toString() on arrays/collections/maps for multi-valued string fields, which may work in some cases but clearly isn't a good solution

@yrodiere yrodiere changed the title HSEARCH-2535 HSEARCH-2535 @Facet on container (Iterable, Array, ...) properties indexes the container's toString() Jan 2, 2017
@yrodiere
Copy link
Member Author

yrodiere commented Jan 3, 2017

Jenkins, test this please

@@ -444,7 +444,7 @@ private void buildDocumentFields(Object instance,
ConversionContext conversionContext,
InstanceInitializer objectInitializer,
final float inheritedBoost,
boolean multiValued,
boolean multiValuedParent,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really convinced it's clearer. What is "Parent"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to suggest a better name. I just meant to mention that it's not the property we're processing that is multi-valued, but its parent property.
What's important is that even though the parent is not multi-valued, the property we're processing still can be.

gsmet
gsmet previously requested changes Jan 3, 2017
Copy link
Member

@gsmet gsmet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a few comments inline. Some are minor nitpicking, some not so much.

@@ -661,10 +661,33 @@ else if ( currentFieldValue instanceof Map ) {
if ( fieldMetadata.hasFacets() ) {
faceting.enableFacetProcessing();
for ( FacetMetadata facetMetadata : fieldMetadata.getFacetMetadata() ) {
if ( multiValuedParent ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/facetting/faceting/ in the commit comment

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -0,0 +1,354 @@
/*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/facetting/faceting/ in the commit comment

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

}

@Indexed
static class StringArrayFacetEntity {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why they are not private? I wouldn't expect them to be used elsewhere in the package.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I originally used Hibernate ORM in the test, and Hibernate ORM cannot instantiate private classes.
But you're right, since the test doesn't use ORM anymore, there's no reason for making the class package-scoped.
Fixed.

@@ -124,6 +125,7 @@ public void stringMap() throws Exception {
}

@Test
@Ignore // HSEARCH-1927 : Range faceting on multiple numeric values does not work
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's not a good idea to commit tests not working then ignore them. It's especially painful when you try to bisect something.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I'll squash that into the previous commit.

}
else if ( member.isArray() ) {
multivalued = true;
for ( Object element : (Object[]) currentFieldValue ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we don't expect array of primitives here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my other PR: #1274

@Facet does not work if we don't also have a @Field. Which means supporting arrays of primitives for facets makes little sense if we have no support for arrays of primitives in the field bridges.

Plus, I wanted to discuss the whole solution of Array.* in a single PR, because it's likely to raise some objections.

@gsmet gsmet self-assigned this Jan 3, 2017
@yrodiere yrodiere dismissed gsmet’s stale review January 4, 2017 09:52

Remarks should have been addressed. Thanks.

…y means 'the property holder might have multiple values'
This test is not related to the facetting of Collection properties, but
to the facetting inside an embedded collection.
…, maps)

Some tests are disabled because they do not pass due to HSEARCH-1927.
@gsmet
Copy link
Member

gsmet commented Jan 4, 2017

I fixed a variable name for consistency and merged (s/multivalued/multiValued/).

Thanks.

@gsmet gsmet closed this Jan 4, 2017
@yrodiere yrodiere deleted the HSEARCH-2535 branch April 11, 2017 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants