Esempio n. 1
0
    def __init__(self):
        index_map = ("from company in docs.Companies "
                     "select new {"
                     "Company = company,"
                     "Address_Country = company.Address.Country}")

        self.index_definition = IndexDefinition(index_map=index_map)
Esempio n. 2
0
    def setUpClass(cls):
        cls.default_url = "http://*****:*****@metadata\"][\"Raven-Entity-Name\"],"
            "LastModified = (DateTime)doc[\"@metadata\"][\"Last-Modified\"],"
            "LastModifiedTicks = ((DateTime)doc[\"@metadata\"][\"Last-Modified\"]).Ticks}"
        )
        cls.index = IndexDefinition(cls.index_map)
        cls.db.put_index("Testing", cls.index, True)
Esempio n. 3
0
    def __init__(self):
        index_map = ("from order in docs.Orders "
                     "select new {"
                     "ShipTo_City = order.ShipTo.City,"
                     "ShipTo_Country = order.ShipTo.Country}")

        self.index_definition = IndexDefinition(index_map=index_map)
Esempio n. 4
0
    def __init__(self):
        index_map = (
            "from order in docs.Orders "
            "select new {"
            "OrderId = order.__document_id,"
            "Delay = order.ShippedAt - ((DateTime?)order.OrderedAt),"
            "Price = Enumerable.Sum(order.Lines, x => "
            "((decimal)((((decimal)x.Quantity) * x.PricePerUnit) * (1M - x.Discount))))}"
        )

        self.index_definition = IndexDefinition(index_map=index_map)
 def setUpClass(cls):
     super(TestByIndexActions, cls).setUpClass()
     cls.patch = ScriptedPatchRequest("this.Name = 'testing';")
     cls.db.put("testing/1", {"Name": "test"},
                {"Raven-Entity-Name": "Testing"})
     cls.operation = Operations(cls.request_handler)
     index_map = ("from doc in docs.Testing "
                  "select new{"
                  "Name = doc.Name}")
     index = IndexDefinition(index_map)
     cls.db.put_index("indexOperation", index, True)
    def __init__(self):
        index_map = ("from song in docs.LastFms "
                     "select new {"
                     "query = new object[] {"
                     "song.artist,"
                     "((object)song.datetime_time),"
                     "song.tags,"
                     "song.title,"
                     "song.track_id}}")

        indexes = {"query": FieldIndexing.analyzed}

        self.index_definition = IndexDefinition(index_map=index_map,
                                                indexes=indexes)
Esempio n. 7
0
    def __init__(self):
        index_map = ("from song in docs.LastFms "
                     "select new {"
                     "Query = new object[] {"
                     "song.Artist,"
                     "((object)song.TimeStamp),"
                     "song.Tags,"
                     "song.Title,"
                     "song.TrackId}}")

        indexes = {"Query": FieldIndexing.analyzed}

        self.index_definition = IndexDefinition(index_map=index_map,
                                                indexes=indexes)
Esempio n. 8
0
    def __init__(self):
        index_map = (
            "from order in docs.Orders "
            "from line in order.Lines "
            "select new{"
            "Product = line.Product,"
            "Count = 1,"
            "Total = ((line.Quantity * line.PricePerUnit) * (1 - line.Discount))}"
        )

        map_reduce = ("from result in results "
                      "group result by result.Product into g "
                      "select new{"
                      "Product = g.Key,"
                      "Count = g.Sum(x => x.Count),"
                      "Total = g.Sum(x => x.Total)}")

        self.index_definition = IndexDefinition(index_map=index_map,
                                                reduce=map_reduce)
Esempio n. 9
0
    def __init__(self):
        index_map = ("from e in docs.Employees "
                     "select new {"
                     "Name = (e.FirstName + \" \") + e.LastName,"
                     "Country = e.Address.Country}",
                     "from c in docs.Companies "
                     "select new {"
                     "Name = c.Name,"
                     "Country = c.Address.Country}",
                     "from s in docs.Suppliers "
                     "select new{"
                     "Name = s.Name,"
                     "Country = s.Address.Country}")

        indexes = {"Country": FieldIndexing.analyzed}
        stores = {"Name": "Yes", "Country": "Yes"}

        self.index_definition = IndexDefinition(index_map=index_map,
                                                name=NameAndCountry.__name__,
                                                indexes=indexes,
                                                stores=stores)
Esempio n. 10
0
 def setUpClass(cls):
     super(TestQuery, cls).setUpClass()
     cls.index_map = ("from doc in docs "
                      "select new {"
                      "name = doc.name,"
                      "key = doc.key,"
                      "doc_id = (doc.name + \" \") + doc.key}")
     cls.index_sort = IndexDefinition(
         index_map=cls.index_map,
         sort_options={"key": SortOptions.float},
         stores={"doc_id": "Yes"})
     cls.db.put_index("Testing_Sort",
                      index_def=cls.index_sort,
                      overwrite=True)
     cls.db.put("products/101", {
         "name": "test101",
         "key": 2,
         "order": "a"
     }, {
         "Raven-Entity-Name": "Products",
         "Raven-Python-Type": Product.__module__ + ".Product"
     })
     cls.db.put("products/10", {
         "name": "test10",
         "key": 3,
         "order": "b"
     }, {})
     cls.db.put("products/106", {
         "name": "test106",
         "key": 4,
         "order": "c"
     }, {})
     cls.db.put("products/107", {
         "name": "test107",
         "key": 5,
         "order": None
     }, {
         "Raven-Entity-Name": "Products",
         "Raven-Python-Type": Product.__module__ + ".Product"
     })
     cls.db.put("products/103", {
         "name": "test107",
         "key": 6
     }, {
         "Raven-Entity-Name": "Products",
         "Raven-Python-Type": Product.__module__ + ".Product"
     })
     cls.db.put("products/108", {
         "name": "new_testing",
         "key": 90,
         "order": "d"
     }, {
         "Raven-Entity-Name": "Products",
         "Raven-Python-Type": Product.__module__ + ".Product"
     })
     cls.db.put("orders/105", {
         "name": "testing_order",
         "key": 92,
         "product": "products/108"
     }, {"Raven-Entity-Name": "Orders"})
     cls.db.put(
         "company/1", {
             "name": "withNesting",
             "product": {
                 "name": "testing_order",
                 "key": 4,
                 "order": None
             }
         }, {"Raven-Entity-Name": "Companies"})
     cls.db.put("specials/1", {"url": "https://ravendb.net/"})
     cls.db.put(
         "specials/2", {
             "url":
             "http://www.example.com/ebx/LinkResolverServlet?classofcontent=Standard&id=63935",
             "date": "2017.03.05T00:00:00.000"
         })
     cls.db.put("specials/3", {
         "wild_cards": "%~#+!$,;'*[]?*",
         "date": "2017.03.05T00:00:01.000"
     })
     cls.document_store = documentstore(cls.default_url,
                                        cls.default_database)
     cls.document_store.initialize()