-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
This feature allows to index points, circles and boxes in PREFIX_TREE mapping for ES. #294
This feature allows to index points, circles and boxes in PREFIX_TREE mapping for ES. #294
Conversation
65fe639
to
6f76edd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work. Can you also update documentation (e.g. elasticsearch.txt and searchpredicates.txt)?
@@ -424,12 +424,12 @@ private void storeTest(String... stores) throws Exception { | |||
|
|||
|
|||
//Update some data | |||
add(store, "doc4", getDocument("I'ts all a big Bob", -100, 11.2, Geoshape.point(48.0, 8.0), Geoshape.line(Arrays.asList(new double[][] {{7.5, 47.5}, {8.5, 48.5}})), Arrays.asList("10", "11", "12"), Sets.newHashSet("10", "11"), Instant.ofEpochSecond(4)), true); | |||
add(store, "doc4", getDocument("I'ts all a big Bob", -100, 11.2, Geoshape.point(-48.0, 8.0), Geoshape.point(-48.0, 8.0), Arrays.asList("10", "11", "12"), Sets.newHashSet("10", "11"), Instant.ofEpochSecond(4)), true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason you changed the sign on the first point latitude?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I want to test the reindexing process for prefix_tree in "doc1" so I change the sign on latitude to be sure that the document has really changed.
I do not want to change all tests thoroughly so I change also the sign en "doc4".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense thanks
6f76edd
to
504f773
Compare
@@ -92,7 +92,7 @@ Additional data types will be supported in the future. | |||
|
|||
[[geoshape]] | |||
=== Geoshape Data Type | |||
The Geoshape data type supports representing a point, circle, box, line, polygon, multi-point, multi-line and multi-polygon. Index backends currently support indexing points, lines and polygons. Indexing multi-point, multi-line and multi-polygon properties has not been tested. | |||
The Geoshape data type supports representing a point, circle, box, line, polygon, multi-point, multi-line and multi-polygon. Index backends currently support indexing points, circles, boxes, lines and polygons. Indexing multi-point, multi-line and multi-polygon properties has not been tested. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add language to make clear that indexing circles and boxes is only supported under Elasticsearch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why only on Elasticsearch ?
Solr is also tested. And I think that the code allow it. https://github.com/JanusGraph/janusgraph/blob/master/janusgraph-solr/src/main/java/org/janusgraph/diskstorage/solr/SolrIndex.java#L361
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, perfect! That code was added in #79 I just hadn't tested circle/box indexing. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor comments
Geoshape.Point p = geoshape.getPoint(); | ||
return new double[]{p.getLongitude(), p.getLatitude()}; | ||
} else if (geoshape.getType() != Geoshape.Type.BOX && geoshape.getType() != Geoshape.Type.CIRCLE) { | ||
} else if (geoshape.getType() == Geoshape.Type.BOX) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is it OK not to catch IOException for BOX but required for CIRCLE?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bump
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it's OK.
IOException is throwed by geoshape.toMap()
For Box, the map is constructed without using geoshape.toMap().
For Circle, the map is constructed with geoshape.toMap().
@@ -583,11 +597,13 @@ private String getAdditionScript(KeyInformation.IndexRetriever informations, Str | |||
switch (keyInformation.getCardinality()) { | |||
case SET: | |||
case LIST: | |||
script.append("ctx._source[\"" + e.field + "\"].add(" + convertToJsType(e.value, scriptLang) + ");"); | |||
script.append("ctx._source[\"" + e.field + "\"].add(" + convertToJsType(e.value, scriptLang, Mapping.getMapping(keyInformation)) + ");"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use a String.format to reduce the number of frame switches
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amcp Switching to String.format
may be a performance hit. I was looking up whether it was preferred over StringBuilder and results seemed to say concatenation and StringBuilder end up being similar (though StringBuilder may be better style), but String.format is 5-20 time slower than both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sjudeng Wow. Thank you for this important learning. StringBuilder is the way to go from now on.
if (hasDualStringMapping(keyInformation)) { | ||
script.append("ctx._source[\"" + getDualMappingName(e.field) + "\"].add(" + convertToJsType(e.value, scriptLang) + ");"); | ||
script.append("ctx._source[\"" + getDualMappingName(e.field) + "\"].add(" + convertToJsType(e.value, scriptLang, Mapping.getMapping(keyInformation)) + ");"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String.format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not an issue!
Signed-off-by: David Clement <[email protected]>
504f773
to
d1a7e58
Compare
…ixPrefixTree This feature allows to index points, circles and boxes in PREFIX_TREE mapping for ES.
…ixPrefixTree This feature allows to index points, circles and boxes in PREFIX_TREE mapping for ES.
I also fix some indentation issue.
#293
Signed-off-by: David Clement [email protected]