sparkly.query_generator package

Submodules

sparkly.query_generator.lucene_query_generator module

class sparkly.query_generator.lucene_query_generator.LuceneQueryGenerator(analyzer, config: IndexConfig, index_reader)

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: dict | Series, query_spec: QuerySpec)

Generate a query for doc given the query spec

Parameters:
docdict | pd.Series

a record that will be used to generate the query

query_specQuerySpec

the template for the query being built

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

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

Parameters:
docdict | pd.Series

a record that will be used to generate the clauses

query_specQuerySpec

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])

Create a new dictionary with keys from iterable and values set to value.

get(key[, default])

Return the value for key if key is in the dictionary, else default.

items()

keys()

pop(key[, default])

If the key is not found, return the default if given; otherwise, raise a KeyError.

popitem(/)

Remove and return a (key, value) pair as a 2-tuple.

setdefault(key[, default])

Insert key with a value of default if key is not in the dictionary.

update([E, ]**F)

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values()

is_subset

to_dict

union

property 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

property filter
is_subset(other) bool
property size
to_dict() dict
union(other)

Module contents