Search in sources :

Example 86 with GraphTraversal

use of org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal in project timbuctoo by HuygensING.

the class FullTextSearchDescriptionTest method filterAlsoFiltersOnTheBackupPropertyFieldIfTheVertexDoesContainTheProperty.

@Test
public void filterAlsoFiltersOnTheBackupPropertyFieldIfTheVertexDoesContainTheProperty() {
    GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex(vertex -> vertex.withTimId("v1").withProperty(BACKUP_PROPERTY, "value1")).withVertex(vertex -> vertex.withTimId("v2").withProperty(PROPERTY, "value2")).withVertex(vertex -> vertex.withTimId("v3").withProperty(PROPERTY, "value").withProperty(BACKUP_PROPERTY, "value1")).build().traversal().V();
    FullTextSearchParameter fullTextSearchParameter = new FullTextSearchParameter(NAME, "value1");
    FullTextSearchDescription instance = createLocalFullTextSearchDescriptionWithBackupProperty(NAME, PROPERTY, BACKUP_PROPERTY);
    instance.filter(traversal, fullTextSearchParameter);
    assertThat(traversal.toList(), containsInAnyOrder(likeVertex().withTimId("v1"), likeVertex().withTimId("v3")));
}
Also used : Matchers.empty(org.hamcrest.Matchers.empty) FullTextSearchDescription.createLocalFullTextSearchDescriptionWithBackupProperty(nl.knaw.huygens.timbuctoo.search.description.fulltext.FullTextSearchDescription.createLocalFullTextSearchDescriptionWithBackupProperty) Test(org.junit.Test) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) GraphTraversal(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal) Assert.assertThat(org.junit.Assert.assertThat) FullTextSearchParameter(nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.FullTextSearchParameter) FullTextSearchDescription.createLocalSimpleFullTextSearchDescription(nl.knaw.huygens.timbuctoo.search.description.fulltext.FullTextSearchDescription.createLocalSimpleFullTextSearchDescription) Matchers.contains(org.hamcrest.Matchers.contains) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) VertexMatcher.likeVertex(nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex) Matchers.is(org.hamcrest.Matchers.is) TestGraphBuilder.newGraph(nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph) Before(org.junit.Before) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) VertexMatcher.likeVertex(nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex) FullTextSearchDescription.createLocalSimpleFullTextSearchDescription(nl.knaw.huygens.timbuctoo.search.description.fulltext.FullTextSearchDescription.createLocalSimpleFullTextSearchDescription) FullTextSearchParameter(nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.FullTextSearchParameter) Test(org.junit.Test)

Example 87 with GraphTraversal

use of org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal in project timbuctoo by HuygensING.

the class FullTextSearchDescriptionTest method filterFiltersCaseIndependent.

@Test
public void filterFiltersCaseIndependent() {
    GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex(vertex -> vertex.withTimId("v1").withProperty(PROPERTY, "Value")).withVertex(vertex -> vertex.withTimId("v2").withProperty(PROPERTY, "VALUE")).withVertex(vertex -> vertex.withTimId("v3").withProperty(PROPERTY, "vALUE")).build().traversal().V();
    FullTextSearchParameter fullTextSearchParameter = new FullTextSearchParameter(NAME, "value");
    instance.filter(traversal, fullTextSearchParameter);
    assertThat(traversal.toList(), containsInAnyOrder(likeVertex().withTimId("v1"), likeVertex().withTimId("v2"), likeVertex().withTimId("v3")));
}
Also used : Matchers.empty(org.hamcrest.Matchers.empty) FullTextSearchDescription.createLocalFullTextSearchDescriptionWithBackupProperty(nl.knaw.huygens.timbuctoo.search.description.fulltext.FullTextSearchDescription.createLocalFullTextSearchDescriptionWithBackupProperty) Test(org.junit.Test) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) GraphTraversal(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal) Assert.assertThat(org.junit.Assert.assertThat) FullTextSearchParameter(nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.FullTextSearchParameter) FullTextSearchDescription.createLocalSimpleFullTextSearchDescription(nl.knaw.huygens.timbuctoo.search.description.fulltext.FullTextSearchDescription.createLocalSimpleFullTextSearchDescription) Matchers.contains(org.hamcrest.Matchers.contains) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) VertexMatcher.likeVertex(nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex) Matchers.is(org.hamcrest.Matchers.is) TestGraphBuilder.newGraph(nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph) Before(org.junit.Before) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) VertexMatcher.likeVertex(nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex) FullTextSearchParameter(nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.FullTextSearchParameter) Test(org.junit.Test)

Example 88 with GraphTraversal

use of org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal in project timbuctoo by HuygensING.

the class FullTextSearchDescriptionTest method filterIncludesTheVerticesWhereTheSearchedValueIsPartOfThePropertyValueOfTheVertex.

@Test
public void filterIncludesTheVerticesWhereTheSearchedValueIsPartOfThePropertyValueOfTheVertex() {
    GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex(vertex -> vertex.withTimId("v1").withProperty(PROPERTY, "value12344324")).withVertex(vertex -> vertex.withTimId("v2").withProperty(PROPERTY, "another value")).withVertex(vertex -> vertex.withTimId("v3").withProperty(PROPERTY, "value1")).build().traversal().V();
    FullTextSearchParameter fullTextSearchParameter = new FullTextSearchParameter(NAME, "value");
    instance.filter(traversal, fullTextSearchParameter);
    assertThat(traversal.toList(), containsInAnyOrder(likeVertex().withTimId("v1"), likeVertex().withTimId("v2"), likeVertex().withTimId("v3")));
}
Also used : Matchers.empty(org.hamcrest.Matchers.empty) FullTextSearchDescription.createLocalFullTextSearchDescriptionWithBackupProperty(nl.knaw.huygens.timbuctoo.search.description.fulltext.FullTextSearchDescription.createLocalFullTextSearchDescriptionWithBackupProperty) Test(org.junit.Test) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) GraphTraversal(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal) Assert.assertThat(org.junit.Assert.assertThat) FullTextSearchParameter(nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.FullTextSearchParameter) FullTextSearchDescription.createLocalSimpleFullTextSearchDescription(nl.knaw.huygens.timbuctoo.search.description.fulltext.FullTextSearchDescription.createLocalSimpleFullTextSearchDescription) Matchers.contains(org.hamcrest.Matchers.contains) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) VertexMatcher.likeVertex(nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex) Matchers.is(org.hamcrest.Matchers.is) TestGraphBuilder.newGraph(nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph) Before(org.junit.Before) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) VertexMatcher.likeVertex(nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex) FullTextSearchParameter(nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.FullTextSearchParameter) Test(org.junit.Test)

Example 89 with GraphTraversal

use of org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal in project timbuctoo by HuygensING.

the class FullTextSearchDescriptionTest method filterFiltersOnABackupFieldIfTheAVertexDoesNotContainThePropertyField.

@Test
public void filterFiltersOnABackupFieldIfTheAVertexDoesNotContainThePropertyField() {
    GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex(vertex -> vertex.withTimId("v1").withProperty(PROPERTY, "value1")).withVertex(vertex -> vertex.withTimId("v2").withProperty(PROPERTY, "value2")).withVertex(vertex -> vertex.withTimId("v3").withProperty(BACKUP_PROPERTY, "value1")).build().traversal().V();
    FullTextSearchParameter fullTextSearchParameter = new FullTextSearchParameter(NAME, "value1");
    FullTextSearchDescription instance = createLocalFullTextSearchDescriptionWithBackupProperty(NAME, PROPERTY, BACKUP_PROPERTY);
    instance.filter(traversal, fullTextSearchParameter);
    assertThat(traversal.toList(), containsInAnyOrder(likeVertex().withTimId("v1"), likeVertex().withTimId("v3")));
}
Also used : Matchers.empty(org.hamcrest.Matchers.empty) FullTextSearchDescription.createLocalFullTextSearchDescriptionWithBackupProperty(nl.knaw.huygens.timbuctoo.search.description.fulltext.FullTextSearchDescription.createLocalFullTextSearchDescriptionWithBackupProperty) Test(org.junit.Test) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) GraphTraversal(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal) Assert.assertThat(org.junit.Assert.assertThat) FullTextSearchParameter(nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.FullTextSearchParameter) FullTextSearchDescription.createLocalSimpleFullTextSearchDescription(nl.knaw.huygens.timbuctoo.search.description.fulltext.FullTextSearchDescription.createLocalSimpleFullTextSearchDescription) Matchers.contains(org.hamcrest.Matchers.contains) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) VertexMatcher.likeVertex(nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex) Matchers.is(org.hamcrest.Matchers.is) TestGraphBuilder.newGraph(nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph) Before(org.junit.Before) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) VertexMatcher.likeVertex(nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex) FullTextSearchDescription.createLocalSimpleFullTextSearchDescription(nl.knaw.huygens.timbuctoo.search.description.fulltext.FullTextSearchDescription.createLocalSimpleFullTextSearchDescription) FullTextSearchParameter(nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.FullTextSearchParameter) Test(org.junit.Test)

Example 90 with GraphTraversal

use of org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal in project timbuctoo by HuygensING.

the class FullTextSearchDescriptionTest method filterFindsTheVertexViaTheBackupPropertyWhenThePropertyDoesNotMatch.

@Test
public void filterFindsTheVertexViaTheBackupPropertyWhenThePropertyDoesNotMatch() {
    // In the real world, the backup property was never reached due to the .coalesce step being
    // satisfied that the PersonNames' empty list mapped to a blank string.
    // A .union step for both however is quite satisfactory because when a user searches, the user wants
    // to search in all available data.
    // This test fails when using .coalesce
    GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex(vertex -> vertex.withTimId("v3").withProperty(PROPERTY, // empty string like in the real world scenario
    "").withProperty(BACKUP_PROPERTY, "value1")).build().traversal().V();
    FullTextSearchParameter fullTextSearchParameter = new FullTextSearchParameter(NAME, "value1");
    FullTextSearchDescription instance = createLocalFullTextSearchDescriptionWithBackupProperty(NAME, PROPERTY, BACKUP_PROPERTY);
    instance.filter(traversal, fullTextSearchParameter);
    assertThat(traversal.toList(), contains(likeVertex().withTimId("v3")));
}
Also used : Matchers.empty(org.hamcrest.Matchers.empty) FullTextSearchDescription.createLocalFullTextSearchDescriptionWithBackupProperty(nl.knaw.huygens.timbuctoo.search.description.fulltext.FullTextSearchDescription.createLocalFullTextSearchDescriptionWithBackupProperty) Test(org.junit.Test) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) GraphTraversal(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal) Assert.assertThat(org.junit.Assert.assertThat) FullTextSearchParameter(nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.FullTextSearchParameter) FullTextSearchDescription.createLocalSimpleFullTextSearchDescription(nl.knaw.huygens.timbuctoo.search.description.fulltext.FullTextSearchDescription.createLocalSimpleFullTextSearchDescription) Matchers.contains(org.hamcrest.Matchers.contains) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) VertexMatcher.likeVertex(nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex) Matchers.is(org.hamcrest.Matchers.is) TestGraphBuilder.newGraph(nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph) Before(org.junit.Before) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) VertexMatcher.likeVertex(nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex) FullTextSearchDescription.createLocalSimpleFullTextSearchDescription(nl.knaw.huygens.timbuctoo.search.description.fulltext.FullTextSearchDescription.createLocalSimpleFullTextSearchDescription) FullTextSearchParameter(nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.FullTextSearchParameter) Test(org.junit.Test)

Aggregations

GraphTraversal (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal)93 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)67 Test (org.junit.Test)57 List (java.util.List)51 TestGraphBuilder.newGraph (nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph)50 VertexMatcher.likeVertex (nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex)44 Before (org.junit.Before)42 Matchers.containsInAnyOrder (org.hamcrest.Matchers.containsInAnyOrder)40 Matchers.contains (org.hamcrest.Matchers.contains)39 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)35 Lists (com.google.common.collect.Lists)34 FacetValue (nl.knaw.huygens.timbuctoo.search.FacetValue)31 Optional (java.util.Optional)24 P (org.apache.tinkerpop.gremlin.process.traversal.P)21 org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__ (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__)20 ListFacetValue (nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.ListFacetValue)19 Matchers.is (org.hamcrest.Matchers.is)17 Mockito.mock (org.mockito.Mockito.mock)17 Matchers.empty (org.hamcrest.Matchers.empty)15 Edge (org.apache.tinkerpop.gremlin.structure.Edge)14