def test_compile_exact_supports_non_list_fields(): query = { 'path': 'reference.arxiv_eprint', 'search_path': 'arxiv_eprints.value.raw', 'type': 'exact', } reference = { 'reference': { 'arxiv_eprint': 'hep-th/9711200', }, } expected = { 'query': { 'bool': { 'should': [ { 'match': { 'arxiv_eprints.value.raw': 'hep-th/9711200', }, }, ], }, }, } result = _compile_exact(query, reference) assert expected == result
def test_compile_exact(): query = { 'path': 'arxiv_eprints.value', 'search_path': 'arxiv_eprints.value.raw', 'type': 'exact', } record = { 'arxiv_eprints': [ { 'categories': [ 'hep-th', ], 'value': 'hep-th/9711200', }, ], } expected = { 'query': { 'bool': { 'should': [ { 'match': { 'arxiv_eprints.value.raw': 'hep-th/9711200', }, }, ], }, }, } result = _compile_exact(query, record) assert expected == result
def test_compile_exact_supports_multiple_collections(): query = { 'collections': [ 'CDS Hidden', 'HAL Hidden', ], 'path': 'arxiv_eprints.value', 'search_path': 'arxiv_eprints.value.raw', 'type': 'exact', } record = { 'arxiv_eprints': [ { 'categories': [ 'hep-th', ], 'value': 'hep-th/9711200', }, ], } expected = { 'query': { 'bool': { 'minimum_should_match': 1, 'filter': { 'bool': { 'should': [ { 'match': { '_collections': 'CDS Hidden', }, }, { 'match': { '_collections': 'HAL Hidden', }, }, ], }, }, 'should': [ { 'match': { 'arxiv_eprints.value.raw': 'hep-th/9711200', }, }, ], }, }, } result = _compile_exact(query, record) assert expected == result