MCPcopy Create free account
hub / github.com/couchbase/couchbase-python-client / search_query

Method search_query

couchbase/scope.py:224–320  ·  view source on GitHub ↗

Executes an search query against the scope. .. warning:: This method is **DEPRECATED** and will be removed in a future release. Use :meth:`~couchbase.scope.Scope.search` instead. .. note:: The search query is executed lazily in that it is execute

(self,
                     index,  # type: str
                     query,  # type: SearchQuery
                     *options,  # type: SearchOptions
                     **kwargs   # type: Dict[str, Any]
                     )

Source from the content-addressed store, hash-verified

222 return self._impl.analytics_query(req)
223
224 def search_query(self,
225 index, # type: str
226 query, # type: SearchQuery
227 *options, # type: SearchOptions
228 **kwargs # type: Dict[str, Any]
229 ) -> SearchResult:
230 """Executes an search query against the scope.
231
232 .. warning::
233 This method is **DEPRECATED** and will be removed in a future release.
234 Use :meth:`~couchbase.scope.Scope.search` instead.
235
236 .. note::
237 The search query is executed lazily in that it is executed once iteration over the
238 :class:`~couchbase.result.SearchResult` begins.
239
240 Args:
241 index (str): Name of the search query to use.
242 query (:class:`~couchbase.search.SearchQuery`): Type of search query to perform.
243 options (:class:`~couchbase.options.SearchOptions`): Optional parameters for the search query
244 operation.
245 **kwargs (Dict[str, Any]): keyword arguments that can be used in place or to
246 override provided :class:`~couchbase.options.SearchOptions`
247
248 Returns:
249 :class:`~couchbase.result.SearchResult`: An instance of a
250 :class:`~couchbase.result.SearchResult` which provides access to iterate over the search
251 query results and access metadata and metrics about the search query.
252
253 Examples:
254
255 .. note::
256 Be sure to create a search index prior to executing search queries. Also, if an application
257 desires to utilize search row locations, highlighting, etc. make sure the search index is
258 setup appropriately. See :search_create_idx:`Creating Indexes <>` in Couchbase Server docs.
259
260 Simple search query::
261
262 import couchbase.search as search
263 from couchbase.options import SearchOptions
264
265 # ... other code ...
266
267 query = search.TermQuery('home')
268 q_res = scope.search_query('travel-sample-index',
269 query,
270 SearchOptions(limit=10))
271
272 for row in q_res.rows():
273 print(f'Found row: {row}')
274
275
276 Simple search query with facets::
277
278 import couchbase.search as search
279 from couchbase.options import SearchOptions
280
281 # ... other code ...

Callers

nothing calls this directly

Calls 3

build_search_requestMethod · 0.45
searchMethod · 0.45

Tested by

no test coverage detected