@@ -24,9 +24,9 @@ from marklogic.documents import Document, DefaultMetadata
2424
2525client = Client('http://localhost:8000', digest=('python-user', 'pyth0n'))
2626client.documents.write([
27- DefaultMetadata(permissions={"rest-reader": ["read", "update"]}, collections=["python-example"]),
28- Document("/doc1.json", {"text": "example one "}),
29- Document("/doc2.json", {"text": "example two "})
27+ DefaultMetadata(permissions={"rest-reader": ["read", "update"]}, collections=["python-search- example"]),
28+ Document("/search/ doc1.json", {"text": "hello world "}),
29+ Document("/search/ doc2.json", {"text": "hello again "})
3030])
3131```
3232
@@ -37,12 +37,12 @@ a search string that utilizes the
3737[ the MarkLogic search grammar] ( https://docs.marklogic.com/guide/search-dev/search-api#id_41745 ) :
3838
3939```
40- # Find documents with the term "example " in them.
41- docs = client.documents.search("example ")
40+ # Find documents with the term "hello " in them.
41+ docs = client.documents.search("hello ")
4242assert len(docs) == 2
4343
44- # Find documents with the term "one " in them.
45- docs = client.documents.search("one ")
44+ # Find documents with the term "world " in them.
45+ docs = client.documents.search("world ")
4646assert len(docs) == 1
4747```
4848
@@ -65,12 +65,12 @@ Examples of a structured query:
6565
6666```
6767# JSON
68- docs = client.documents.search(query={"query": {"term-query": {"text": "example "}}})
68+ docs = client.documents.search(query={"query": {"term-query": {"text": "hello "}}})
6969assert len(docs) == 2
7070
7171# XML
7272query = "<query xmlns='http://marklogic.com/appservices/search'>\
73- <term-query><text>example </text></term-query></query>"
73+ <term-query><text>hello </text></term-query></query>"
7474docs = client.documents.search(query=query)
7575assert len(docs) == 2
7676```
@@ -79,12 +79,12 @@ Examples of a serialized CTS query:
7979
8080```
8181# JSON
82- query = {"ctsquery": {"wordQuery": {"text": "example "}}}
82+ query = {"ctsquery": {"wordQuery": {"text": "hello "}}}
8383docs = client.documents.search(query=query)
8484assert len(docs) == 2
8585
8686# XML
87- query = "<word-query xmlns='http://marklogic.com/cts'><text>world </text></word-query>"
87+ query = "<word-query xmlns='http://marklogic.com/cts'><text>hello </text></word-query>"
8888docs = client.documents.search(query=query)
8989assert len(docs) == 2
9090```
@@ -96,15 +96,15 @@ Examples of a combined query:
9696options = {"constraint": {"name": "c1", "word": {"element": {"name": "text"}}}}
9797query = {
9898 "search": {"options": options},
99- "qtext": "c1:example ",
99+ "qtext": "c1:hello ",
100100}
101101docs = client.documents.search(query=query)
102102assert len(docs) == 2
103103
104104# XML
105105query = "<search xmlns='http://marklogic.com/appservices/search'><options>\
106106 <constraint name='c1'><word><element name='text'/></word></constraint>\
107- </options><qtext>c1:example </qtext></search>"
107+ </options><qtext>c1:hello </qtext></search>"
108108docs = client.documents.search(query=query)
109109assert len(docs) == 2
110110```
@@ -116,11 +116,11 @@ more commonly used parameters are available as arguments in the `client.document
116116
117117```
118118# Specify the starting point and page length.
119- docs = client.documents.search("example ", start=2, page_length=5)
119+ docs = client.documents.search("hello ", start=2, page_length=5)
120120assert len(docs) == 1
121121
122122# Search via a collection without any search string.
123- docs = client.documents.search(collections=["python-example"])
123+ docs = client.documents.search(collections=["python-search- example"])
124124assert len(docs) == 2
125125```
126126
@@ -129,12 +129,12 @@ each matching document:
129129
130130```
131131# Retrieve all content and metadata for each matching document.
132- docs = client.documents.search("example ", categories=["content", "metadata"])
133- assert "python-example" in docs[0].collections
134- assert "python-example" in docs[1].collections
132+ docs = client.documents.search("hello ", categories=["content", "metadata"])
133+ assert "python-search- example" in docs[0].collections
134+ assert "python-search- example" in docs[1].collections
135135
136136# Retrieve only permissions for each matching document.
137- docs = client.documents.search("example ", categories=["permissions"])
137+ docs = client.documents.search("hello ", categories=["permissions"])
138138assert docs[0].content is None
139139assert docs[1].content is None
140140```
@@ -145,7 +145,7 @@ The `client.documents.search` method provides a `**kwargs` argument, so you can
145145normally pass to ` requests ` . For example:
146146
147147```
148- docs = client.documents.search("example ", params={"database": "Documents"})
148+ docs = client.documents.search("hello ", params={"database": "Documents"})
149149assert len(docs) == 2
150150```
151151
0 commit comments