Exemplo n.º 1
0
 def set_query(self, query):
     """
     Set the query object
     @param query:
     @type query: str or pylastica.query.Query or pylastica.query.abstract.AbstractQuery
     @return:
     @rtype: self
     """
     query = pylastica.query.Query.create(query)
     data = query.to_dict()
     return self.set_param('query', data['query'])
Exemplo n.º 2
0
 def set_query(self, query):
     """
     Set the query object
     @param query: query
     @type query: str or pylastica.query.Query or pylastica.query.abstract.AbstractQuery
     @return:
     @rtype: self
     """
     query = pylastica.query.Query.create(query)
     data = query.to_dict()
     return self.set_param('query', data['query'])
Exemplo n.º 3
0
 def count(self, query=None):
     """
     Counts results for a query. If no query is set, a MatchAll query is used.
     @param query: dict with all query data or a Query object
     @type query: dict or pylastica.query.Query
     @return: number of docs matching the query
     @rtype: int
     """
     self.set_options_and_query(None, query)
     query = self.query
     response = self.client.request(self.path, data=query.to_dict(), query={self.OPTION_SEARCH_TYPE: self.SEARCH_TYPE_COUNT})
     return pylastica.resultset.ResultSet(response, query).get_total_hits()
Exemplo n.º 4
0
 def search(self, query=None, options=None):
     """
     Search in the set indices and types
     @param query:
     @type query: mixed
     @param options: optional limit or dict of options
     @type options: int or dict
     @return:
     @rtype: pylastica.resultset.ResultSet
     """
     self.set_options_and_query(options, query)
     query = self.query
     response = self.client.request(self.path, data=query.to_dict(), query=self.options)
     return pylastica.resultset.ResultSet(response, query)
Exemplo n.º 5
0
 def count(self, query=None):
     """
     Counts results for a query. If no query is set, a MatchAll query is used.
     @param query: dict with all query data or a Query object
     @type query: dict or pylastica.query.Query
     @return: number of docs matching the query
     @rtype: int
     """
     self.set_options_and_query(None, query)
     query = self.query
     response = self.client.request(
         self.path,
         data=query.to_dict(),
         query={self.OPTION_SEARCH_TYPE: self.SEARCH_TYPE_COUNT})
     return pylastica.resultset.ResultSet(response, query).get_total_hits()
Exemplo n.º 6
0
 def search(self, query=None, options=None):
     """
     Search in the set indices and types
     @param query:
     @type query: mixed
     @param options: optional limit or dict of options
     @type options: int or dict
     @return:
     @rtype: pylastica.resultset.ResultSet
     """
     self.set_options_and_query(options, query)
     query = self.query
     response = self.client.request(self.path,
                                    data=query.to_dict(),
                                    query=self.options)
     return pylastica.resultset.ResultSet(response, query)