Search in sources :

Example 1 with FullTextSearchParameter

use of nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.FullTextSearchParameter in project timbuctoo by HuygensING.

the class FullTextSearchDescriptionTest method filterFiltersTheVerticesOnTheValueOfTheProperty.

@Test
public void filterFiltersTheVerticesOnTheValueOfTheProperty() {
    GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex(vertex -> vertex.withTimId("v1").withProperty(PROPERTY, "value1")).withVertex(vertex -> vertex.withTimId("v2").withProperty(PROPERTY, "number2")).withVertex(vertex -> vertex.withTimId("v3").withProperty(PROPERTY, "value1")).build().traversal().V();
    FullTextSearchParameter searchParameter = new FullTextSearchParameter(NAME, "value1");
    instance.filter(traversal, searchParameter);
    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) FullTextSearchParameter(nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.FullTextSearchParameter) Test(org.junit.Test)

Example 2 with FullTextSearchParameter

use of nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.FullTextSearchParameter in project timbuctoo by HuygensING.

the class FullTextSearchDescriptionTest method filterFiltersAllTheVerticesFromTheTraversalWhenNoneMatch.

@Test
public void filterFiltersAllTheVerticesFromTheTraversalWhenNoneMatch() {
    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(PROPERTY, "value").withProperty(BACKUP_PROPERTY, "value1")).build().traversal().V();
    FullTextSearchParameter fullTextSearchParameter = new FullTextSearchParameter(NAME, "Not matching");
    FullTextSearchDescription instance = createLocalFullTextSearchDescriptionWithBackupProperty(NAME, PROPERTY, BACKUP_PROPERTY);
    instance.filter(traversal, fullTextSearchParameter);
    assertThat(traversal.toList(), is(empty()));
}
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 3 with FullTextSearchParameter

use of nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.FullTextSearchParameter in project timbuctoo by HuygensING.

the class FullTextSearchDescriptionTest method filterFiltersOnEachOfTheTermIndividuallyEachPropertyHasToContainOnlyOne.

@Test
public void filterFiltersOnEachOfTheTermIndividuallyEachPropertyHasToContainOnlyOne() {
    GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex(vertex -> vertex.withTimId("v1").withProperty(PROPERTY, "value 12344324 value2")).withVertex(vertex -> vertex.withTimId("v2").withProperty(PROPERTY, "value value2")).withVertex(vertex -> vertex.withTimId("v3").withProperty(PROPERTY, "value1 value2")).build().traversal().V();
    FullTextSearchParameter fullTextSearchParameter = new FullTextSearchParameter(NAME, "value value2");
    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 4 with FullTextSearchParameter

use of nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.FullTextSearchParameter 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 5 with FullTextSearchParameter

use of nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.FullTextSearchParameter 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)

Aggregations

FullTextSearchDescription.createLocalFullTextSearchDescriptionWithBackupProperty (nl.knaw.huygens.timbuctoo.search.description.fulltext.FullTextSearchDescription.createLocalFullTextSearchDescriptionWithBackupProperty)9 FullTextSearchDescription.createLocalSimpleFullTextSearchDescription (nl.knaw.huygens.timbuctoo.search.description.fulltext.FullTextSearchDescription.createLocalSimpleFullTextSearchDescription)9 FullTextSearchParameter (nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.FullTextSearchParameter)9 TestGraphBuilder.newGraph (nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph)9 VertexMatcher.likeVertex (nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex)9 GraphTraversal (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal)9 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)9 Matchers.contains (org.hamcrest.Matchers.contains)9 Matchers.containsInAnyOrder (org.hamcrest.Matchers.containsInAnyOrder)9 Matchers.empty (org.hamcrest.Matchers.empty)9 Matchers.is (org.hamcrest.Matchers.is)9 Assert.assertThat (org.junit.Assert.assertThat)9 Before (org.junit.Before)9 Test (org.junit.Test)9