コード例 #1
0
 def setUp(self):
     super(NestedTest, self).setUp()
     self._index = self._create_index("test_aggregation_nested")
     mapping = Mapping()
     mapping.set_properties({
         "resellers": {
             "type": "nested",
             "properties": {
                 "name": {
                     "type": "string"
                 },
                 "price": {
                     "type": "double"
                 }
             }
         }
     })
     doc_type = self._index.get_doc_type("test")
     doc_type.mapping = mapping
     docs = [
         Document(
             1, {"resellers": {
                 "name": "spacely sprockets",
                 "price": 5.55
             }}),
         Document(2,
                  {"resellers": {
                      "name": "cogswell cogs",
                      "price": 4.98
                  }})
     ]
     doc_type.add_documents(docs)
     self._index.refresh()
コード例 #2
0
 def setUp(self):
     super(MyTestCase, self).setUp()
     self._index = self._create_index("simple_query_string_test")
     docs = [
         Document(1, {
             'make': 'Gibson',
             'model': 'Les Paul'
         }),
         Document(2, {
             'make': 'Gibson',
             'model': 'SG Standard'
         }),
         Document(3, {
             'make': 'Gibson',
             'model': 'SG Supreme'
         }),
         Document(4, {
             'make': 'Gibson',
             'model': 'SG Faded'
         }),
         Document(5, {
             'make': 'Fender',
             'model': 'Stratocaster'
         })
     ]
     self._index.get_doc_type("guitars").add_documents(docs)
     self._index.refresh()
コード例 #3
0
ファイル: test_max.py プロジェクト: jlinn/pylastica
 def setUp(self):
     super(MaxTest, self).setUp()
     self._index = self._create_index("test_aggregation_max")
     docs = [
         Document("1", {"price": 5}),
         Document("2", {"price": 8}),
         Document("3", {"price": 1}),
         Document("4", {"price": 3})
     ]
     self._index.get_doc_type("test").add_documents(docs)
     self._index.refresh()
コード例 #4
0
ファイル: test_snapshot.py プロジェクト: jlinn/pylastica
    def setUp(self):
        super(SnapshotTest, self).setUp()
        self._snapshot = self._get_client().snapshot

        self._index = self._create_index("test_snapshot")
        self._docs = [
            Document("1", {"city": "San Diego"}),
            Document("2", {"city": "San Luis Obispo"}),
            Document("3", {"city": "San Francisco"})
        ]
        self._index.get_doc_type("test").add_documents(self._docs)
        self._index.refresh()
コード例 #5
0
ファイル: test_daterange.py プロジェクト: jlinn/pylastica
 def setUp(self):
     super(DateRangeTest, self).setUp()
     self._index = self._create_index("test_aggregation_date_range")
     mapping = Mapping()
     mapping.set_properties({"created": {"type": "date"}})
     doc_type = self._index.get_doc_type("test")
     doc_type.mapping = mapping
     docs = [
         Document("1", {"created": 1390962135000}),
         Document("2", {"created": 1390965735000}),
         Document("3", {"created": 1390954935000})
     ]
     doc_type.add_documents(docs)
     self._index.refresh()
コード例 #6
0
ファイル: test_indices.py プロジェクト: jlinn/pylastica
 def setUp(self):
     super(IndicesTest, self).setUp()
     self._index1 = self._create_index("indices_filter_1")
     self._index2 = self._create_index("indices_filter_2")
     self._index1.add_alias("indices_filter")
     self._index2.add_alias("indices_filter")
     docs = [
         Document("1", {"color": "blue"}),
         Document("2", {"color": "green"}),
         Document("3", {"color": "blue"}),
         Document("4", {"color": "yellow"}),
     ]
     self._index1.get_doc_type("test").add_documents(docs)
     self._index2.get_doc_type("test").add_documents(docs)
     self._index1.refresh()
     self._index2.refresh()
コード例 #7
0
    def test_scroll(self):
        search = pylastica.Search(self._get_client())

        index = self._create_index("test_scroll")
        doc_type = index.get_doc_type("test")
        doc_type.add_documents([Document(i, {"clicks": randint(0, 100)}) for i in range(0, 100)])
        index.refresh()

        search.add_index(index)
        doc_ids = set()
        for result in search.scroll("2m", options={"size": 11}):
            doc_ids.add(result.get_id())

        self.assertEqual(100, len(doc_ids))