marklogic 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.editorconfig +10 -0
- data/.gitignore +15 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +17 -0
- data/Guardfile +45 -0
- data/LICENSE.txt +21 -0
- data/README.md +31 -0
- data/Rakefile +6 -0
- data/lib/marklogic.rb +21 -0
- data/lib/marklogic/app_server.rb +60 -0
- data/lib/marklogic/application.rb +244 -0
- data/lib/marklogic/collection.rb +265 -0
- data/lib/marklogic/connection.rb +308 -0
- data/lib/marklogic/consts.rb +35 -0
- data/lib/marklogic/cursor.rb +238 -0
- data/lib/marklogic/database.rb +205 -0
- data/lib/marklogic/database_settings.rb +13 -0
- data/lib/marklogic/database_settings/element_word_lexicon.rb +28 -0
- data/lib/marklogic/database_settings/geospatial_element_child_index.rb +41 -0
- data/lib/marklogic/database_settings/geospatial_element_index.rb +38 -0
- data/lib/marklogic/database_settings/geospatial_element_pair_index.rb +42 -0
- data/lib/marklogic/database_settings/geospatial_path_index.rb +37 -0
- data/lib/marklogic/database_settings/index.rb +27 -0
- data/lib/marklogic/database_settings/range_element_index.rb +77 -0
- data/lib/marklogic/database_settings/range_field_index.rb +37 -0
- data/lib/marklogic/database_settings/range_path_index.rb +37 -0
- data/lib/marklogic/exceptions.rb +5 -0
- data/lib/marklogic/forest.rb +47 -0
- data/lib/marklogic/loggable.rb +46 -0
- data/lib/marklogic/object_id.rb +46 -0
- data/lib/marklogic/persistence.rb +29 -0
- data/lib/marklogic/queries.rb +18 -0
- data/lib/marklogic/queries/and_not_query.rb +14 -0
- data/lib/marklogic/queries/and_query.rb +14 -0
- data/lib/marklogic/queries/base_query.rb +40 -0
- data/lib/marklogic/queries/boost_query.rb +14 -0
- data/lib/marklogic/queries/collection_query.rb +14 -0
- data/lib/marklogic/queries/container_query.rb +15 -0
- data/lib/marklogic/queries/directory_query.rb +20 -0
- data/lib/marklogic/queries/document_fragment_query.rb +13 -0
- data/lib/marklogic/queries/document_query.rb +14 -0
- data/lib/marklogic/queries/geospatial_query.rb +44 -0
- data/lib/marklogic/queries/locks_fragment_query.rb +13 -0
- data/lib/marklogic/queries/near_query.rb +31 -0
- data/lib/marklogic/queries/not_in_query.rb +14 -0
- data/lib/marklogic/queries/not_query.rb +13 -0
- data/lib/marklogic/queries/or_query.rb +24 -0
- data/lib/marklogic/queries/properties_fragment_query.rb +13 -0
- data/lib/marklogic/queries/range_query.rb +67 -0
- data/lib/marklogic/queries/value_query.rb +44 -0
- data/lib/marklogic/queries/word_query.rb +38 -0
- data/lib/marklogic/version.rb +3 -0
- data/marklogic.gemspec +23 -0
- data/spec/marklogic/app_server_spec.rb +21 -0
- data/spec/marklogic/application_spec.rb +105 -0
- data/spec/marklogic/collection_spec.rb +154 -0
- data/spec/marklogic/connection_spec.rb +128 -0
- data/spec/marklogic/cursor_spec.rb +219 -0
- data/spec/marklogic/database_settings/element_word_lexicon_spec.rb +21 -0
- data/spec/marklogic/database_settings/geospatial_element_child_index_spec.rb +26 -0
- data/spec/marklogic/database_settings/geospatial_element_index_spec.rb +24 -0
- data/spec/marklogic/database_settings/geospatial_element_pair_index_spec.rb +27 -0
- data/spec/marklogic/database_settings/geospatial_path_index_spec.rb +23 -0
- data/spec/marklogic/database_settings/range_element_index_spec.rb +34 -0
- data/spec/marklogic/database_settings/range_field_index_spec.rb +23 -0
- data/spec/marklogic/database_settings/range_path_index_spec.rb +23 -0
- data/spec/marklogic/database_spec.rb +108 -0
- data/spec/marklogic/forest_spec.rb +30 -0
- data/spec/marklogic/queries/and_not_query_spec.rb +13 -0
- data/spec/marklogic/queries/and_query_spec.rb +31 -0
- data/spec/marklogic/queries/boost_query_spec.rb +13 -0
- data/spec/marklogic/queries/collection_query_spec.rb +16 -0
- data/spec/marklogic/queries/container_query_spec.rb +11 -0
- data/spec/marklogic/queries/directory_query_spec.rb +21 -0
- data/spec/marklogic/queries/document_fragment_query_spec.rb +11 -0
- data/spec/marklogic/queries/document_query_spec.rb +16 -0
- data/spec/marklogic/queries/locks_fragement_query_spec.rb +11 -0
- data/spec/marklogic/queries/near_query_spec.rb +62 -0
- data/spec/marklogic/queries/not_in_query_spec.rb +13 -0
- data/spec/marklogic/queries/not_query_spec.rb +11 -0
- data/spec/marklogic/queries/or_query_spec.rb +32 -0
- data/spec/marklogic/queries/properties_fragment_query_spec.rb +11 -0
- data/spec/marklogic/queries/range_query_spec.rb +71 -0
- data/spec/marklogic/queries/value_query_spec.rb +68 -0
- data/spec/marklogic/queries/word_query_spec.rb +53 -0
- data/spec/spec_helper.rb +68 -0
- metadata +186 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MarkLogic::DatabaseSettings::GeospatialPathIndex do
|
4
|
+
let(:index) do
|
5
|
+
MarkLogic::DatabaseSettings::GeospatialPathIndex.new("/path/to/stuff")
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "new" do
|
9
|
+
it "should populate correctly" do
|
10
|
+
expect(index.to_json).to eq(
|
11
|
+
{
|
12
|
+
"geospatial-path-index" => {
|
13
|
+
"path-expression" => "/path/to/stuff",
|
14
|
+
"coordinate-system" => "wgs84",
|
15
|
+
"point-format" => "point",
|
16
|
+
"range-value-positions" => false,
|
17
|
+
"invalid-values" => "reject"
|
18
|
+
}
|
19
|
+
}
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MarkLogic::DatabaseSettings::RangeElementIndex do
|
4
|
+
|
5
|
+
describe "new" do
|
6
|
+
it "should populate correctly" do
|
7
|
+
index = MarkLogic::DatabaseSettings::RangeElementIndex.new("element")
|
8
|
+
expect(index.to_json).to eq(
|
9
|
+
{
|
10
|
+
"scalar-type" => "string",
|
11
|
+
"namespace-uri" => "",
|
12
|
+
"localname" => "element",
|
13
|
+
"collation" => MarkLogic::DEFAULT_COLLATION,
|
14
|
+
"range-value-positions" => false,
|
15
|
+
"invalid-values" => "reject"
|
16
|
+
}
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should populate correctly with namespace-uri" do
|
21
|
+
index = MarkLogic::DatabaseSettings::RangeElementIndex.new("element", :namespace => "blah")
|
22
|
+
expect(index.to_json).to eq(
|
23
|
+
{
|
24
|
+
"scalar-type" => "string",
|
25
|
+
"namespace-uri" => "blah",
|
26
|
+
"localname" => "element",
|
27
|
+
"collation" => MarkLogic::DEFAULT_COLLATION,
|
28
|
+
"range-value-positions" => false,
|
29
|
+
"invalid-values" => "reject"
|
30
|
+
}
|
31
|
+
)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MarkLogic::DatabaseSettings::RangeFieldIndex do
|
4
|
+
let(:index) do
|
5
|
+
MarkLogic::DatabaseSettings::RangeFieldIndex.new("field")
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "new" do
|
9
|
+
it "should populate correctly" do
|
10
|
+
expect(index.to_json).to eq(
|
11
|
+
{
|
12
|
+
"range-field-index" => {
|
13
|
+
"scalar-type" => "string",
|
14
|
+
"field-name" => "field",
|
15
|
+
"collation" => MarkLogic::DEFAULT_COLLATION,
|
16
|
+
"range-value-positions" => false,
|
17
|
+
"invalid-values" => "reject"
|
18
|
+
}
|
19
|
+
}
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MarkLogic::DatabaseSettings::RangePathIndex do
|
4
|
+
let(:index) do
|
5
|
+
MarkLogic::DatabaseSettings::RangePathIndex.new("/path/to/stuff")
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "new" do
|
9
|
+
it "should populate correctly" do
|
10
|
+
expect(index.to_json).to eq(
|
11
|
+
{
|
12
|
+
"range-path-index" => {
|
13
|
+
"scalar-type" => "string",
|
14
|
+
"collation" => MarkLogic::DEFAULT_COLLATION,
|
15
|
+
"path-expression" => "/path/to/stuff",
|
16
|
+
"range-value-positions" => false,
|
17
|
+
"invalid-values" => "reject"
|
18
|
+
}
|
19
|
+
}
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MarkLogic::Database do
|
4
|
+
|
5
|
+
describe "instance" do
|
6
|
+
let(:d) do
|
7
|
+
MarkLogic::Database.new("marklogic-gem-test")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should create accessors" do
|
11
|
+
expect(d.database_name).to eq("marklogic-gem-test")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should create adders" do
|
15
|
+
d.add_range_element_index("stuff")
|
16
|
+
expect(d['range-element-index'].length).to eq(1)
|
17
|
+
expect(d['range-element-index'][0].to_json).to eq(
|
18
|
+
{
|
19
|
+
"scalar-type" => "string",
|
20
|
+
"namespace-uri" => "",
|
21
|
+
"localname" => "stuff",
|
22
|
+
"collation" => MarkLogic::DEFAULT_COLLATION,
|
23
|
+
"range-value-positions" => false,
|
24
|
+
"invalid-values" => "reject"
|
25
|
+
}
|
26
|
+
)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "stale?" do
|
31
|
+
let(:d) do
|
32
|
+
MarkLogic::Database.new("marklogic-gem-test")
|
33
|
+
end
|
34
|
+
|
35
|
+
before do
|
36
|
+
d.drop if d.exists?
|
37
|
+
d.create
|
38
|
+
end
|
39
|
+
|
40
|
+
after do
|
41
|
+
d.reset_indexes
|
42
|
+
d.drop
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should determine stale state properly" do
|
46
|
+
|
47
|
+
expect(d).to be_exists
|
48
|
+
expect(d).to_not be_stale
|
49
|
+
|
50
|
+
d.add_range_element_index("junk")
|
51
|
+
|
52
|
+
expect(d).to be_stale
|
53
|
+
|
54
|
+
d.update
|
55
|
+
|
56
|
+
expect(d).to_not be_stale
|
57
|
+
|
58
|
+
d.add_range_element_index("whut")
|
59
|
+
d.add_range_element_index("stuff")
|
60
|
+
|
61
|
+
expect(d).to be_stale
|
62
|
+
|
63
|
+
d.update
|
64
|
+
|
65
|
+
d.reset_indexes
|
66
|
+
|
67
|
+
d.add_range_element_index("whut")
|
68
|
+
d.add_range_element_index("stuff")
|
69
|
+
d.add_range_element_index("junk")
|
70
|
+
|
71
|
+
expect(d).to_not be_stale
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe "#collections" do
|
76
|
+
let(:d) do
|
77
|
+
MarkLogic::Database.new("marklogic-gem-test", CONNECTION)
|
78
|
+
end
|
79
|
+
|
80
|
+
before do
|
81
|
+
# d.drop if d.exists?
|
82
|
+
d.create
|
83
|
+
end
|
84
|
+
|
85
|
+
after do
|
86
|
+
d.drop
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should return empty array when no collections are present" do
|
90
|
+
d.collections.each do |collection|
|
91
|
+
d.collection(collection).drop
|
92
|
+
end
|
93
|
+
expect(d.collections.count).to eq(0)
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should return collections" do
|
97
|
+
collection = d.collection("my-test")
|
98
|
+
collection.save({ name: "testing" })
|
99
|
+
collection = d.collection("my-test2")
|
100
|
+
collection.save({ name: "testing2" })
|
101
|
+
|
102
|
+
expect(d.collections.count).to eq(2)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
describe "#clear" do
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MarkLogic::Forest do
|
4
|
+
|
5
|
+
describe "#init" do
|
6
|
+
let(:forest) do
|
7
|
+
MarkLogic::Forest.new("marklogic-gem-test")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should create accessors" do
|
11
|
+
expect(forest.forest_name).to eq("marklogic-gem-test")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "#create" do
|
16
|
+
before do
|
17
|
+
@forest = MarkLogic::Forest.new("marklogic-gem-test")
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should create a forest" do
|
21
|
+
expect(@forest).to_not be_exists
|
22
|
+
@forest.create
|
23
|
+
expect(@forest).to be_exists
|
24
|
+
|
25
|
+
@forest.drop
|
26
|
+
expect(@forest).to_not be_exists
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MarkLogic::Queries::AndNotQuery do
|
4
|
+
|
5
|
+
describe "#to_xqy" do
|
6
|
+
it "should create xquery correctly" do
|
7
|
+
q = MarkLogic::Queries::AndNotQuery.new(
|
8
|
+
MarkLogic::Queries::DirectoryQuery.new("/foo/"),
|
9
|
+
MarkLogic::Queries::CollectionQuery.new("bar"))
|
10
|
+
expect(q.to_xqy).to eq(%Q{cts:and-not-query(cts:directory-query(("/foo/")),cts:collection-query(("bar")))})
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MarkLogic::Queries::AndQuery do
|
4
|
+
|
5
|
+
describe "#to_xqy" do
|
6
|
+
it "should create xquery correctly" do
|
7
|
+
q = MarkLogic::Queries::AndQuery.new
|
8
|
+
expect(q.to_xqy).to eq(%Q{cts:and-query(())})
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should create xquery correctly" do
|
12
|
+
q = MarkLogic::Queries::AndQuery.new([])
|
13
|
+
expect(q.to_xqy).to eq(%Q{cts:and-query(())})
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should create xquery correctly" do
|
17
|
+
q = MarkLogic::Queries::AndQuery.new([
|
18
|
+
MarkLogic::Queries::DirectoryQuery.new("/foo/")
|
19
|
+
])
|
20
|
+
expect(q.to_xqy).to eq(%Q{cts:and-query((cts:directory-query(("/foo/"))))})
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should create xquery correctly" do
|
24
|
+
q = MarkLogic::Queries::AndQuery.new([
|
25
|
+
MarkLogic::Queries::DirectoryQuery.new("/foo/"),
|
26
|
+
MarkLogic::Queries::DirectoryQuery.new("/bar/")
|
27
|
+
])
|
28
|
+
expect(q.to_xqy).to eq(%Q{cts:and-query((cts:directory-query(("/foo/")),cts:directory-query(("/bar/"))))})
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MarkLogic::Queries::BoostQuery do
|
4
|
+
|
5
|
+
describe "#to_xqy" do
|
6
|
+
it "should create xquery correctly" do
|
7
|
+
q = MarkLogic::Queries::BoostQuery.new(
|
8
|
+
MarkLogic::Queries::DirectoryQuery.new("/foo/"),
|
9
|
+
MarkLogic::Queries::CollectionQuery.new("bar"))
|
10
|
+
expect(q.to_xqy).to eq(%Q{cts:boost-query(cts:directory-query(("/foo/")),cts:collection-query(("bar")))})
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MarkLogic::Queries::CollectionQuery do
|
4
|
+
|
5
|
+
describe "#to_xqy" do
|
6
|
+
it "should handle a single collection" do
|
7
|
+
q = MarkLogic::Queries::CollectionQuery.new("foo")
|
8
|
+
expect(q.to_xqy).to eq(%Q{cts:collection-query(("foo"))})
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should handle multiple collections" do
|
12
|
+
q = MarkLogic::Queries::CollectionQuery.new(["foo", "bar", "baz"])
|
13
|
+
expect(q.to_xqy).to eq(%Q{cts:collection-query(("foo","bar","baz"))})
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MarkLogic::Queries::ContainerQuery do
|
4
|
+
|
5
|
+
describe "#to_xqy" do
|
6
|
+
it "should create xquery correctly" do
|
7
|
+
q = MarkLogic::Queries::ContainerQuery.new("foo", MarkLogic::Queries::ValueQuery.new("bar", "baz"))
|
8
|
+
expect(q.to_xqy).to eq(%Q{cts:json-property-scope-query("foo",cts:json-property-value-query("bar",("baz"),("exact"),1.0))})
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MarkLogic::Queries::DirectoryQuery do
|
4
|
+
|
5
|
+
describe "#to_xqy" do
|
6
|
+
it "should have a default depth" do
|
7
|
+
q = MarkLogic::Queries::DirectoryQuery.new("/foo/")
|
8
|
+
expect(q.to_xqy).to eq(%Q{cts:directory-query(("/foo/"))})
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should accept a supplied depth" do
|
12
|
+
q = MarkLogic::Queries::DirectoryQuery.new("/foo/", "infinity")
|
13
|
+
expect(q.to_xqy).to eq(%Q{cts:directory-query(("/foo/"),"infinity")})
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should accept multiple uri" do
|
17
|
+
q = MarkLogic::Queries::DirectoryQuery.new(["/foo/", "/bar/", "/baz/"], "infinity")
|
18
|
+
expect(q.to_xqy).to eq(%Q{cts:directory-query(("/foo/","/bar/","/baz/"),"infinity")})
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MarkLogic::Queries::DocumentFragmentQuery do
|
4
|
+
|
5
|
+
describe "#to_xqy" do
|
6
|
+
it "should create xquery correctly" do
|
7
|
+
q = MarkLogic::Queries::DocumentFragmentQuery.new(MarkLogic::Queries::ValueQuery.new("bar", "baz"))
|
8
|
+
expect(q.to_xqy).to eq(%Q{cts:document-fragment-query(cts:json-property-value-query("bar",("baz"),("exact"),1.0))})
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MarkLogic::Queries::DocumentQuery do
|
4
|
+
|
5
|
+
describe "#to_xqy" do
|
6
|
+
it "should have a default depth" do
|
7
|
+
q = MarkLogic::Queries::DocumentQuery.new("/foo/blah.json")
|
8
|
+
expect(q.to_xqy).to eq(%Q{cts:document-query(("/foo/blah.json"))})
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should accept multiple uris" do
|
12
|
+
q = MarkLogic::Queries::DocumentQuery.new(["/foo/blah.json", "/bar/stuff.json"])
|
13
|
+
expect(q.to_xqy).to eq(%Q{cts:document-query(("/foo/blah.json","/bar/stuff.json"))})
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MarkLogic::Queries::LocksFragmentQuery do
|
4
|
+
|
5
|
+
describe "#to_xqy" do
|
6
|
+
it "should create xquery correctly" do
|
7
|
+
q = MarkLogic::Queries::LocksFragmentQuery.new(MarkLogic::Queries::ValueQuery.new("bar", "baz"))
|
8
|
+
expect(q.to_xqy).to eq(%Q{cts:locks-fragment-query(cts:json-property-value-query("bar",("baz"),("exact"),1.0))})
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MarkLogic::Queries::NearQuery do
|
4
|
+
|
5
|
+
describe "#to_xqy" do
|
6
|
+
it "should handle a single query" do
|
7
|
+
q = MarkLogic::Queries::NearQuery.new([
|
8
|
+
MarkLogic::Queries::DirectoryQuery.new("/foo/")
|
9
|
+
])
|
10
|
+
expect(q.to_xqy).to eq(%Q{cts:near-query((cts:directory-query(("/foo/"))),10,(),1.0)})
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should handle multiple queries" do
|
14
|
+
q = MarkLogic::Queries::NearQuery.new([
|
15
|
+
MarkLogic::Queries::DirectoryQuery.new("/foo/"),
|
16
|
+
MarkLogic::Queries::DirectoryQuery.new("/bar/")
|
17
|
+
])
|
18
|
+
expect(q.to_xqy).to eq(%Q{cts:near-query((cts:directory-query(("/foo/")),cts:directory-query(("/bar/"))),10,(),1.0)})
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should handle multiple queries with a distance" do
|
22
|
+
q = MarkLogic::Queries::NearQuery.new([
|
23
|
+
MarkLogic::Queries::DirectoryQuery.new("/foo/"),
|
24
|
+
MarkLogic::Queries::DirectoryQuery.new("/bar/")
|
25
|
+
],
|
26
|
+
5)
|
27
|
+
expect(q.to_xqy).to eq(%Q{cts:near-query((cts:directory-query(("/foo/")),cts:directory-query(("/bar/"))),5,(),1.0)})
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should handle multiple queries with a distance and weight" do
|
31
|
+
q = MarkLogic::Queries::NearQuery.new([
|
32
|
+
MarkLogic::Queries::DirectoryQuery.new("/foo/"),
|
33
|
+
MarkLogic::Queries::DirectoryQuery.new("/bar/")
|
34
|
+
],
|
35
|
+
5,
|
36
|
+
2.0)
|
37
|
+
expect(q.to_xqy).to eq(%Q{cts:near-query((cts:directory-query(("/foo/")),cts:directory-query(("/bar/"))),5,(),2.0)})
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should handle multiple queries with a distance and weight and unordered" do
|
41
|
+
q = MarkLogic::Queries::NearQuery.new([
|
42
|
+
MarkLogic::Queries::DirectoryQuery.new("/foo/"),
|
43
|
+
MarkLogic::Queries::DirectoryQuery.new("/bar/")
|
44
|
+
],
|
45
|
+
5,
|
46
|
+
2.0,
|
47
|
+
ordered: false)
|
48
|
+
expect(q.to_xqy).to eq(%Q{cts:near-query((cts:directory-query(("/foo/")),cts:directory-query(("/bar/"))),5,("unordered"),2.0)})
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should handle multiple queries with a distance and weight and unordered" do
|
52
|
+
q = MarkLogic::Queries::NearQuery.new([
|
53
|
+
MarkLogic::Queries::DirectoryQuery.new("/foo/"),
|
54
|
+
MarkLogic::Queries::DirectoryQuery.new("/bar/")
|
55
|
+
],
|
56
|
+
5,
|
57
|
+
2.0,
|
58
|
+
ordered: true)
|
59
|
+
expect(q.to_xqy).to eq(%Q{cts:near-query((cts:directory-query(("/foo/")),cts:directory-query(("/bar/"))),5,("ordered"),2.0)})
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|