def text_query(text): """Part of a query which finds a piece of text.""" if text is None or not len(text.strip()): return match_all() return { "bool": { "minimum_should_match": 1, "should": [ meta_query_string(text), child_record({"bool": { "should": [text_query_string(text)] }}) ] } }
def text_query(text): """Part of a query which finds a piece of text.""" if text is None or not len(text.strip()): return match_all() return { "bool": { "minimum_should_match": 1, "should": [ meta_query_string(text), child_record({ "bool": { "should": [text_query_string(text)] } }) ] } }
def text_query(text): """ Construct the part of a query which is responsible for finding a piece of thext in the selected documents. """ if text is None or not len(text.strip()): return match_all() return { "bool": { "minimum_should_match": 1, "should": [ meta_query_string(text), child_record({ "bool": { "should": [text_query_string(text)] } }) ] } }
def analyze_terms(terms, seen=None): if seen is None: seen = set() for term in terms: query = { "bool": { "minimum_should_match": 1, "should": [ meta_query_string(term, literal=True), child_record({ "bool": { "should": [text_query_string(term, literal=True)] } }) ] } } for doc_id in query_doc_ids(query): if doc_id not in seen: analyze_document.delay(doc_id) seen.add(doc_id)
def analyze_terms(terms, seen=None): if seen is None: seen = set() for term in terms: term = normalize_strong(term) query = { "bool": { "minimum_should_match": 1, "should": [ meta_query_string(term), child_record( {"bool": { "should": [text_query_string(term)] }}) ] } } for doc_id in query_doc_ids(query): if doc_id not in seen: analyze_document.delay(doc_id) seen.add(doc_id)