sparkly.query_generator package

Submodules

sparkly.query_generator.lucene_query_generator module

class sparkly.query_generator.lucene_query_generator.LuceneQueryGenerator(analyzer, config)

Bases: object

A class for generating queries for Lucene based indexes

Methods

generate_query(doc, query_spec) Generate a query for doc given the query spec
generate_query_clauses(doc, query_spec) generate the clauses for each field -> analyzer pair, filters are ignored
generate_query(doc, query_spec)

Generate a query for doc given the query spec

Parameters:
doc : dict | pd.Series

a record that will be used to generate the query

query_spec : QuerySpec

the template for the query being built

Returns:
A lucene query which can be passed to an index searcher
generate_query_clauses(doc, query_spec)

generate the clauses for each field -> analyzer pair, filters are ignored

Parameters:
doc : dict | pd.Series

a record that will be used to generate the clauses

query_spec : QuerySpec

the template for the query being built

Returns:
A dict of ((field, indexed_fields) -> BooleanQuery)

sparkly.query_generator.query_spec module

class sparkly.query_generator.query_spec.QuerySpec(*args, **kwargs)

Bases: dict

A specification for generating queries

Attributes:
boost_map

The boosting weights for each (search_field -> indexed_field) pair.

filter
size

Methods

clear()
copy()
fromkeys(iterable[, value]) Returns a new dict with keys from iterable and values equal to value.
get(k[,d])
items()
keys()
pop(k[,d]) If key is not found, d is returned if given, otherwise KeyError is raised
popitem() 2-tuple; but raise KeyError if D is empty.
setdefault(k[,d])
update([E, ]**F) If E is present and has a .keys() method, then does: for k in E: D[k] = E[k]
values()
is_subset  
to_dict  
union  
boost_map

The boosting weights for each (search_field -> indexed_field) pair. If a pair doesn’t exist in the map, the boost weight is 1

filter
is_subset(other)
size
to_dict()
union(other)

Module contents