Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1550,6 +1550,15 @@ public void testDualMapping() {
1, new boolean[]{true, true}, "mixed");
evaluateQuery(tx.query().has("name", Text.CONTAINS_FUZZY, "Midle"), ElementCategory.VERTEX,
1, new boolean[]{true, true}, "mixed");
evaluateQuery(tx.query().orderBy("name", asc), ElementCategory.VERTEX,
3, new boolean[]{false, false}, tx.getPropertyKey("name"), Order.ASC);
evaluateQuery(tx.query().orderBy("name", desc), ElementCategory.VERTEX,
3, new boolean[]{false, false}, tx.getPropertyKey("name"), Order.DESC);
evaluateQuery(tx.query().has("name", Text.CONTAINS, "Long").orderBy("name", asc), ElementCategory.VERTEX,
2, new boolean[]{true, true}, tx.getPropertyKey("name"), Order.ASC, "mixed");
evaluateQuery(tx.query().has("name", Text.CONTAINS, "Long").orderBy("name", desc), ElementCategory.VERTEX,
2, new boolean[]{true, true}, tx.getPropertyKey("name"), Order.DESC, "mixed");

for (final Vertex u : tx.getVertices()) {
final String n = u.value("name");
if (n.endsWith("Don")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,8 @@ private void addOrderToQuery(KeyInformation.IndexRetriever informations, Elastic
final KeyInformation information = informations.get(store).get(orderEntry.getKey());
final Mapping mapping = Mapping.getMapping(information);
final Class<?> datatype = orderEntry.getDatatype();
sr.addSort(orderEntry.getKey(), order.toLowerCase(), convertToEsDataType(datatype, mapping));
final String key = hasDualStringMapping(information) ? getDualMappingName(orderEntry.getKey()) : orderEntry.getKey();
sr.addSort(key, order.toLowerCase(), convertToEsDataType(datatype, mapping));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import com.google.common.base.Throwables;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Multimap;

import org.apache.commons.configuration.BaseConfiguration;
Expand Down Expand Up @@ -43,6 +44,7 @@
import org.janusgraph.diskstorage.indexing.*;
import org.janusgraph.core.schema.Mapping;
import org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration;
import org.janusgraph.graphdb.internal.Order;
import org.janusgraph.graphdb.query.condition.PredicateCondition;
import org.janusgraph.graphdb.types.ParameterType;
import org.json.simple.JSONObject;
Expand Down Expand Up @@ -405,6 +407,32 @@ public void testTextStringMapping() throws Exception {
assertEquals(2, tx.queryStream(new IndexQuery("vertex", PredicateCondition.of(TEXT_STRING, Text.CONTAINS, "John"))).count());
}

@Test
public void testTextStringSort() throws Exception {
initialize("vertex");

Multimap<String, Object> firstDoc = HashMultimap.create();
firstDoc.put(TEXT_STRING, "John Doe");

Multimap<String, Object> secondDoc = HashMultimap.create();
secondDoc.put(TEXT_STRING, "Jane Doe");

add("vertex", "test1", firstDoc, true);
add("vertex", "test2", secondDoc, true);

clopen();

Object[] result = tx.queryStream(new IndexQuery("vertex", PredicateCondition.of(TEXT_STRING, Text.CONTAINS, "Doe"),
ImmutableList.of(new IndexQuery.OrderEntry(TEXT_STRING, Order.ASC, String.class)))).toArray();
assertEquals("test2", result[0]);
assertEquals("test1", result[1]);

result = tx.queryStream(new IndexQuery("vertex", PredicateCondition.of(TEXT_STRING, Text.CONTAINS, "Doe"),
ImmutableList.of(new IndexQuery.OrderEntry(TEXT_STRING, Order.DESC, String.class)))).toArray();
assertEquals("test1", result[0]);
assertEquals("test2", result[1]);
}

@Test
public void testShouldNotShareIndexStoreNameCacheBetweenElasticSearchIndexInstances() throws BackendException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
final String index1 = "es1";
Expand Down