Exemplo n.º 1
0
def get_catalogue_choices(keywords):
    """
    获取选项
    :param keywords:
    :return:
    """

    from app_backend.clients.client_es import es_client
    from app_common.libs.es import ES

    es = ES(es_client)

    index = 'catalogue'
    doc_type = 'bearing'
    # field = 'product_label'
    field = 'product_model'
    # keywords = '7008ACDGA/P4A'
    query_from = 0
    size = 0

    es_result = es.search_fulltext(index, doc_type, field, keywords, query_from, size)

    catalogue_choices = map(lambda x: (
        x['id'], x['value'], '%s <small class="text-muted">%s</small>' % (x['label'], x['info']['product_brand']),
        x['info']['product_brand']), es_result['data'])
    return catalogue_choices
@time: 2018-04-16 22:23
"""

from __future__ import unicode_literals
from __future__ import print_function

from app_backend import app
from app_backend.api.catalogue import get_catalogue_limit_rows_by_last_id
from app_backend.clients.client_es import es_client
from app_common.libs.es import ES

# 推送上下文
ctx = app.app_context()
ctx.push()

es = ES(es_client)


def import_catalogue():
    pk_id = 0
    limit = 200
    import_count = 0

    index = 'catalogue'
    doc_type = 'bearing'
    mapping = {
        'properties': {
            'product_brand': {
                'type': 'text',
                'analyzer': 'ik_max_word',
            },
Exemplo n.º 3
0
 def setUp(self):
     self.es = ES(es_client)
     self.index = 'test_index_01'
     self.doc_type = 'test_doc_type_01'