Пример #1
0
    def test_query(self):
        query = SimpleQueryString("gibson +sg +-faded", ["make", "model"])
        results = self._index.search(query)

        self.assertEqual(2, results.get_total_hits())

        query.set_fields(["model"])
        results = self._index.search(query)

        self.assertEqual(0, results.get_total_hits())
Пример #2
0
    def test_query(self):
        query = SimpleQueryString("gibson +sg +-faded", ["make", "model"])
        results = self._index.search(query)

        self.assertEqual(2, results.get_total_hits())

        query.set_fields(["model"])
        results = self._index.search(query)

        self.assertEqual(0, results.get_total_hits())
Пример #3
0
    def test_to_dict(self):
        string = "this is a test"
        fields = ['field1', 'field2']
        query = SimpleQueryString(string, fields)
        query.set_default_operator(SimpleQueryString.OPERATOR_OR)
        query.set_analyzer("whitespace")

        expected = {
            "simple_query_string": {
                "query": string,
                "fields": fields,
                "analyzer": "whitespace",
                "default_operator": SimpleQueryString.OPERATOR_OR
            }
        }

        self.assertEqual(expected, query.to_dict())
Пример #4
0
    def test_to_dict(self):
        string = "this is a test"
        fields = ['field1', 'field2']
        query = SimpleQueryString(string, fields)
        query.set_default_operator(SimpleQueryString.OPERATOR_OR)
        query.set_analyzer("whitespace")

        expected = {
            "simple_query_string": {
                "query": string,
                "fields": fields,
                "analyzer": "whitespace",
                "default_operator": SimpleQueryString.OPERATOR_OR
            }
        }

        self.assertEqual(expected, query.to_dict())