Exemplo n.º 1
0
    def _test_search_by_fuzzy(self, schema, graphson):
        """
        Test to validate that solr searches by distance.

        @since 1.0.0
        @jira_ticket PYTHON-664
        @expected_result all names with a geo location within a 2 radius distance of -92,44 are returned

        @test_category dse graph
        """
        self.execute_graph(schema.fixtures.address_book(), graphson)
        g = self.fetch_traversal_source(graphson)
        traversal = g.V().has("person", "name", Search.fuzzy("Paul Thamas Joe", 1)).values("name")
        results_list = self.execute_traversal(traversal, graphson)
        self.assertEqual(len(results_list), 1)
        self.assertIn("Paul Thomas Joe", results_list)

        traversal = g.V().has("person", "name", Search.fuzzy("Paul Thames Joe", 1)).values("name")
        results_list = self.execute_traversal(traversal, graphson)
        self.assertEqual(len(results_list), 0)
Exemplo n.º 2
0
    def _test_search_by_phrase(self, schema, graphson):
        """
        Test to validate that phrase searches.

        @since 1.0.0
        @jira_ticket PYTHON-664
        @expected_result all names with that differ from the search phrase criteria by two letter should be returned

        @test_category dse graph
        """
        self.execute_graph(schema.fixtures.address_book(), graphson)
        g = self.fetch_traversal_source(graphson)
        traversal = g.V().has("person", "description", Search.phrase("a cold", 2)).values("name")
        #Should match 'George Bill Steve' since 'A cold dude' is at distance of 0 for 'a cold'.
        #Should match 'Jill Alice' since 'Enjoys a very nice cold coca cola' is at distance of 2 for 'a cold'.
        results_list = self.execute_traversal(traversal, graphson)
        self.assertEqual(len(results_list), 2)
        self.assertIn('George Bill Steve', results_list)
        self.assertIn('Jill Alice', results_list)

        traversal = g.V().has("person", "description", Search.phrase("a bald", 2)).values("name")
        results_list = self.execute_traversal(traversal, graphson)
        self.assertEqual(len(results_list), 0)
Exemplo n.º 3
0
    def _test_search_by_fuzzy_token(self, schema, graphson):
        """
        Test to validate that fuzzy searches.

        @since 1.0.0
        @jira_ticket PYTHON-664
        @expected_result all names with that differ from the search criteria by one letter should be returned

        @test_category dse graph
        """
        self.execute_graph(schema.fixtures.address_book(), graphson)
        g = self.fetch_traversal_source(graphson)
        traversal = g.V().has("person", "description", Search.token_fuzzy("lives", 1)).values("name")
        # Should match 'Paul Thomas Joe' since description contains 'Lives'
        # Should match 'James Paul Joe' since description contains 'Likes'
        results_list = self.execute_traversal(traversal, graphson)
        self.assertEqual(len(results_list), 2)
        self.assertIn("Paul Thomas Joe", results_list)
        self.assertIn("James Paul Smith", results_list)

        traversal = g.V().has("person", "description", Search.token_fuzzy("loues", 1)).values("name")
        results_list = self.execute_traversal(traversal, graphson)
        self.assertEqual(len(results_list), 0)
Exemplo n.º 4
0
    def test_search_by_prefix(self):
        """
        Test to validate that solr searches by prefix function.

        @since 1.0.0
        @jira_ticket PYTHON-660
        @expected_result all names starting with Paul should be returned

        @test_category dse graph
        """
        g = self.fetch_traversal_source()
        traversal = g.V().has("person", "name",
                              Search.prefix("Paul")).values("name")
        results_list = self.execute_traversal(traversal)
        self.assertEqual(len(results_list), 1)
        self.assertEqual(results_list[0], "Paul Thomas Joe")
Exemplo n.º 5
0
    def test_search_by_token_prefix(self):
        """
        Test to validate that solr searches by token prefix.

        @since 1.0.0
        @jira_ticket PYTHON-660
        @expected_result all names with description containing a token starting with h are returned

        @test_category dse graph
        """
        g = self.fetch_traversal_source()
        traversal = g.V().has("person", "description",
                              Search.token_prefix("h")).values("name")
        results_list = self.execute_traversal(traversal)
        self.assertEqual(len(results_list), 2)
        self.assertIn("Paul Thomas Joe", results_list)
        self.assertIn("James Paul Smith", results_list)
Exemplo n.º 6
0
    def test_search_by_token(self):
        """
        Test to validate that solr searches by token.

        @since 1.0.0
        @jira_ticket PYTHON-660
        @expected_result all names with description containing could shoud be returned

        @test_category dse graph
        """
        g = self.fetch_traversal_source()
        traversal = g.V().has("person", "description",
                              Search.token("cold")).values("name")
        results_list = self.execute_traversal(traversal)
        self.assertEqual(len(results_list), 2)
        self.assertIn("Jill Alice", results_list)
        self.assertIn("George Bill Steve", results_list)
Exemplo n.º 7
0
    def test_search_by_regex(self):
        """
        Test to validate that solr searches by regex function.

        @since 1.0.0
        @jira_ticket PYTHON-660
        @expected_result all names containing Paul should be returned

        @test_category dse graph
        """
        g = self.fetch_traversal_source()
        traversal = g.V().has("person", "name",
                              Search.regex(".*Paul.*")).values("name")
        results_list = self.execute_traversal(traversal)
        self.assertEqual(len(results_list), 2)
        self.assertIn("Paul Thomas Joe", results_list)
        self.assertIn("James Paul Smith", results_list)
Exemplo n.º 8
0
    def _test_search_by_token_regex(self, schema, graphson):
        """
        Test to validate that solr searches by token regex.

        @since 1.0.0
        @jira_ticket PYTHON-660
        @expected_result all names with description containing nice or hospital are returned

        @test_category dse graph
        """
        self.execute_graph(schema.fixtures.address_book(), graphson)
        g = self.fetch_traversal_source(graphson)
        traversal = g.V().has("person", "description", Search.token_regex("(nice|hospital)")).values("name")
        results_list = self.execute_traversal(traversal, graphson)
        self.assertEqual(len(results_list), 2)
        self.assertIn("Paul Thomas Joe", results_list )
        self.assertIn( "Jill Alice", results_list )