Example #1
0
def create_test_store(host, namespace):
    return ElasticStoreSync(hosts=host,
                            namespace=NAMESPACE,
                            type=namespace,
                            fulltext_indexes=['body'],
                            feature_indexes=[{
                                'NAME': {
                                    'es_index_type': 'string',
                                    'feature_names': ['NAME']
                                },
                            }, {
                                'boNAME': {
                                    'es_index_type': 'string',
                                    'feature_names': ['boNAME']
                                },
                            }])
Example #2
0
def test_fulltext_mapping_keyword(elastic_address, namespace_string,
                                  fcs_texts):
    store = ElasticStoreSync(hosts=elastic_address,
                             namespace=NAMESPACE,
                             type=namespace_string,
                             fulltext_indexes=[{
                                 'body': ['body2'],
                             }])
    try:
        store.put(fcs_texts)

        query = FC({'body': {'vision': 1}})
        assert frozenset(map(itemgetter(1),
                             store.fulltext_scan_ids(query_fc=query))) \
            == frozenset(['boss'])
    finally:
        store.delete_all()
Example #3
0
def test_fulltext_mapping_keyword(elastic_address, namespace_string,
                                  fcs_texts):
    store = ElasticStoreSync(
        hosts=elastic_address, namespace=NAMESPACE, type=namespace_string,
        fulltext_indexes=[{
            'body': ['body2'],
        }])
    try:
        store.put(fcs_texts)

        query = FC({'body': {'vision': 1}})
        assert frozenset(map(itemgetter(1),
                             store.fulltext_scan_ids(query_fc=query))) \
            == frozenset(['boss'])
    finally:
        store.delete_all()
Example #4
0
def test_index_mapping_raw_scan(elastic_address, namespace_string, fcs):
    store = ElasticStoreSync(
        hosts=elastic_address, namespace=NAMESPACE, type=namespace_string,
        feature_indexes=[{
            'NAME': {
                'es_index_type': 'string',
                'feature_names': ['NAME', 'boNAME'],
            },
        }, {
            'boNAME': {'es_index_type': 'string', 'feature_names': []},
        }])
    try:
        store.put(fcs)

        assert frozenset(store.index_scan_ids('NAME', 'The Boss')) \
            == frozenset(['boss'])
        assert frozenset(store.index_scan_ids('NAME', 'clarence')) \
            == frozenset(['big-man'])
    finally:
        store.delete_all()
Example #5
0
def test_index_mapping_raw_scan(elastic_address, namespace_string, fcs):
    store = ElasticStoreSync(hosts=elastic_address,
                             namespace=NAMESPACE,
                             type=namespace_string,
                             feature_indexes=[{
                                 'NAME': {
                                     'es_index_type': 'string',
                                     'feature_names': ['NAME', 'boNAME'],
                                 },
                             }, {
                                 'boNAME': {
                                     'es_index_type': 'string',
                                     'feature_names': []
                                 },
                             }])
    try:
        store.put(fcs)

        assert frozenset(store.index_scan_ids('NAME', 'The Boss')) \
            == frozenset(['boss'])
        assert frozenset(store.index_scan_ids('NAME', 'clarence')) \
            == frozenset(['big-man'])
    finally:
        store.delete_all()
Example #6
0
def test_index_mapping_keyword(elastic_address, namespace_string, fcs):
    store = ElasticStoreSync(
        hosts=elastic_address, namespace=NAMESPACE, type=namespace_string,
        feature_indexes=[{
            'NAME': {
                'es_index_type': 'string',
                'feature_names': ['NAME', 'boNAME'],
            },
        }, {
            'boNAME': {'es_index_type': 'string', 'feature_names': []},
        }])
    try:
        store.put(fcs)

        query = FC({'NAME': {'The Boss': 1, 'clarence': 1}})
        assert frozenset(store.keyword_scan_ids('ephemeral', query)) \
            == frozenset(['boss', 'big-man'])
    finally:
        store.delete_all()
Example #7
0
def test_index_mapping_keyword(elastic_address, namespace_string, fcs):
    store = ElasticStoreSync(hosts=elastic_address,
                             namespace=NAMESPACE,
                             type=namespace_string,
                             feature_indexes=[{
                                 'NAME': {
                                     'es_index_type': 'string',
                                     'feature_names': ['NAME', 'boNAME'],
                                 },
                             }, {
                                 'boNAME': {
                                     'es_index_type': 'string',
                                     'feature_names': []
                                 },
                             }])
    try:
        store.put(fcs)

        query = FC({'NAME': {'The Boss': 1, 'clarence': 1}})
        assert frozenset(store.keyword_scan_ids('ephemeral', query)) \
            == frozenset(['boss', 'big-man'])
    finally:
        store.delete_all()