Esempio n. 1
0
    def test_create_field_range(self):
        db = Database("foo")

        field = Field("invoice-id")
        db.add_field(field)

        field_range = FieldRange("invoice-id", "int")
        db.add_index(field_range)

        index = db.field_range_index(0)
        self.assertEqual("invoice-id", index.name())
        self.assertEqual("int", index.type())

        indexes = db.field_range_index()
        self.assertEqual(1, len(indexes))
    def test_create_field_range(self):
        db = Database("foo")

        field = Field("invoice-id")
        db.add_field(field)

        field_range = FieldRange("invoice-id", "int")
        db.add_index(field_range)

        index = db.field_range_index(0)
        self.assertEqual("invoice-id", index.name())
        self.assertEqual("int", index.type())

        indexes = db.field_range_index()
        self.assertEqual(1, len(indexes))
Esempio n. 3
0
#
# Copyright 2015 MarkLogic Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

from marklogic.models import Connection, Database, FieldRange, Field, FieldReference
from requests.auth import HTTPDigestAuth

auth = HTTPDigestAuth("admin", "admin")

conn = Connection("192.168.57.141", auth)

db = Database("range-field-test", "localhost.localdomain")
field = Field("test-field", includes=[FieldReference("http://foo.bar.com/invoice", "id")])
db.add_field(field)
db.add_index(FieldRange("test-field", "int"))

db.create(conn)
from requests.auth import HTTPDigestAuth
from marklogic.models import Database, Connection, Host, HttpServer, ElementRange, ElementAttributeRange

conn = Connection("192.168.57.141", HTTPDigestAuth("admin", "admin"))

server_hostname = hosts = Host.list_hosts(conn)[0].host_name()

db = Database("test-one", server_hostname)
db.create(conn).load_file(conn, "example_doc.json", "/test/document.json",
                          ["example", "collection"])

modules = Database("test-one-modules", server_hostname)
modules.create(conn)

db = Database.lookup("test-one", conn)
db.add_index(ElementRange("order-id", u'int'))
db.add_index(
    ElementAttributeRange("customer",
                          "id",
                          scalar_type=u'int',
                          element_namespace="http://foo.bar.com"))
db.save(conn)

srvr = HttpServer("test-one-http", 8400)
srvr.set_content_database(db.config[u'database-name']).set_modules_database(
    modules.config[u'database-name'])
srvr.create(conn)

db.load_file(conn, "example_doc.json", "/example/file.json", ["test"])
db.load_directory_files(conn, "data", "/test/data/", ["test2"])
db.load_directory(conn, "data", collections=["this", "that"])
Esempio n. 5
0
__author__ = 'phoehne'

from requests.auth import HTTPDigestAuth
from marklogic.models import Database, Connection, Host, HttpServer, ElementRange, ElementAttributeRange

conn = Connection("192.168.57.141", HTTPDigestAuth("admin", "admin"))

server_hostname = hosts = Host.list_hosts(conn)[0].host_name()

db = Database("test-one", server_hostname)
db.create(conn).load_file(conn, "example_doc.json", "/test/document.json", ["example", "collection"])

modules = Database("test-one-modules", server_hostname)
modules.create(conn)

db = Database.lookup("test-one", conn)
db.add_index(ElementRange("order-id", u'int'))
db.add_index(ElementAttributeRange("customer", "id", scalar_type=u'int', element_namespace="http://foo.bar.com"))
db.save(conn)

srvr = HttpServer("test-one-http", 8400)
srvr.set_content_database(db.config[u'database-name']).set_modules_database(modules.config[u'database-name'])
srvr.create(conn)

db.load_file(conn, "example_doc.json", "/example/file.json", ["test"])
db.load_directory_files(conn, "data", "/test/data/", ["test2"])
db.load_directory(conn, "data", collections=["this", "that"])