当前位置: 首页>>代码示例>>Python>>正文


Python SearchEngineFactory.delete_index方法代码示例

本文整理汇总了Python中arches.app.search.search_engine_factory.SearchEngineFactory.delete_index方法的典型用法代码示例。如果您正苦于以下问题:Python SearchEngineFactory.delete_index方法的具体用法?Python SearchEngineFactory.delete_index怎么用?Python SearchEngineFactory.delete_index使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在arches.app.search.search_engine_factory.SearchEngineFactory的用法示例。


在下文中一共展示了SearchEngineFactory.delete_index方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: index_resources

# 需要导入模块: from arches.app.search.search_engine_factory import SearchEngineFactory [as 别名]
# 或者: from arches.app.search.search_engine_factory.SearchEngineFactory import delete_index [as 别名]
def index_resources():
    """
    Deletes any existing indicies from elasticsearch related to resources 
    and then indexes all resources from the database

    """

    result_summary = {}
    se = SearchEngineFactory().create()

    # clear existing indexes
    for index_type in ['resource_relations', 'entity', 'resource', 'maplayers']:
        se.delete_index(index=index_type)
    se.delete(index='term', body='{"query":{"bool":{"must":[{"constant_score":{"filter":{"missing":{"field":"value.options.conceptid"}}}}],"must_not":[],"should":[]}}}')

    Resource().prepare_term_index(create=True)

    cursor = connection.cursor()
    cursor.execute("""select entitytypeid from data.entity_types where isresource = TRUE""")
    resource_types = cursor.fetchall()
    Resource().prepare_resource_relations_index(create=True)

    for resource_type in resource_types:
        Resource().prepare_search_index(resource_type[0], create=True)
    
    index_resources_by_type(resource_types, result_summary)

    se.es.indices.refresh(index='entity')
    for resource_type in resource_types:
        result_summary[resource_type[0]]['indexed'] = se.es.count(index="entity", doc_type=resource_type[0])['count']

    print '\nResource Index Results:'
    for k, v in result_summary.iteritems():
        status = 'Passed' if v['database'] == v['indexed'] else 'failed'
        print "Status: {0}, Resource Type: {1}, In Database: {2}, Indexed: {3}".format(status, k, v['database'], v['indexed'])
开发者ID:1000camels,项目名称:arches,代码行数:37,代码来源:index_database.py

示例2: setUpClass

# 需要导入模块: from arches.app.search.search_engine_factory import SearchEngineFactory [as 别名]
# 或者: from arches.app.search.search_engine_factory.SearchEngineFactory import delete_index [as 别名]
 def setUpClass(cls):
     se = SearchEngineFactory().create()
     se.delete_index(index="concept_labels")
     se.delete_index(index="term")
     se.create_index(index="concept_labels")
     se.create_index(index="term")
     management.call_command(
         "packages", operation="import_json", source="tests/fixtures/resource_graphs/archesv4_resource.json"
     )
开发者ID:archesproject,项目名称:arches,代码行数:11,代码来源:concept_import_tests.py

示例3: index_concepts

# 需要导入模块: from arches.app.search.search_engine_factory import SearchEngineFactory [as 别名]
# 或者: from arches.app.search.search_engine_factory.SearchEngineFactory import delete_index [as 别名]
def index_concepts():
    """
    Collects all concepts and indexes both concepts and concept_labels

    """

    se = SearchEngineFactory().create()
    se.delete_index(index='concept_labels')
    se.delete(index='term', body='{"query":{"bool":{"must_not":[{"constant_score":{"filter":{"missing":{"field":"value.options.conceptid"}}}}],"must":[],"should":[]}}}')

    Resource().prepare_term_index(create=True)

    print 'indexing concepts'
    start = datetime.now()

    cursor = connection.cursor()
    cursor.execute("""select conceptid from concepts.concepts""")
    conceptids = cursor.fetchall()
    for c in conceptids:
        if c[0] not in CORE_CONCEPTS:
            concept = Concept().get(id=c[0], include_subconcepts=True, include_parentconcepts=False, include=['label'])
            concept.index()

    end = datetime.now()
    duration = end - start
    print 'indexing concepts required', duration.seconds, 'seconds'

    cursor = connection.cursor()
    sql = """
        select conceptid, conceptlabel from concepts.vw_concepts where conceptid not in ('%s')
    """ % ("','".join(CORE_CONCEPTS))
    cursor.execute(sql)
    concepts = cursor.fetchall()
    concept_index_results = {'count':len(concepts), 'passed':0, 'failed':0}

    for conceptid, conceptvalue in concepts:
        result = get_indexed_concepts(se, conceptid, conceptvalue)
        if result != 'passed':
            concept_index_results['failed'] += 1
        else:
            concept_index_results['passed'] += 1

    status = 'Passed' if concept_index_results['failed'] == 0 else 'Failed'
    print '\nConcept Index Results:'
    print "Status: {0}, In Database: {1}, Indexed: {2}".format(status, concept_index_results['count'], concept_index_results['passed'])
开发者ID:1000camels,项目名称:arches,代码行数:47,代码来源:index_database.py

示例4: delete_index

# 需要导入模块: from arches.app.search.search_engine_factory import SearchEngineFactory [as 别名]
# 或者: from arches.app.search.search_engine_factory.SearchEngineFactory import delete_index [as 别名]
 def delete_index(self, index):
     se = SearchEngineFactory().create()
     se.delete_index(index=index)
开发者ID:bojankastelic,项目名称:ew,代码行数:5,代码来源:index_concepts.py

示例5: setUpClass

# 需要导入模块: from arches.app.search.search_engine_factory import SearchEngineFactory [as 别名]
# 或者: from arches.app.search.search_engine_factory.SearchEngineFactory import delete_index [as 别名]
 def setUpClass(cls):
     se = SearchEngineFactory().create()
     se.delete_index(index='test')
开发者ID:archesproject,项目名称:arches,代码行数:5,代码来源:search_tests.py

示例6: tearDownClass

# 需要导入模块: from arches.app.search.search_engine_factory import SearchEngineFactory [as 别名]
# 或者: from arches.app.search.search_engine_factory.SearchEngineFactory import delete_index [as 别名]
	def tearDownClass(cls):
		se = SearchEngineFactory().create()
		se.delete_index(index='strings')
		se.create_index(index='strings')
开发者ID:azerbini,项目名称:eamena,代码行数:6,代码来源:concept_import_tests.py

示例7: delete_term_index

# 需要导入模块: from arches.app.search.search_engine_factory import SearchEngineFactory [as 别名]
# 或者: from arches.app.search.search_engine_factory.SearchEngineFactory import delete_index [as 别名]
def delete_term_index():
    se = SearchEngineFactory().create()
    se.delete_index(index='strings')
开发者ID:fargeo,项目名称:arches,代码行数:5,代码来源:mappings.py

示例8: delete_resource_relations_index

# 需要导入模块: from arches.app.search.search_engine_factory import SearchEngineFactory [as 别名]
# 或者: from arches.app.search.search_engine_factory.SearchEngineFactory import delete_index [as 别名]
def delete_resource_relations_index():
    se = SearchEngineFactory().create()
    se.delete_index(index='resource_relations')
开发者ID:fargeo,项目名称:arches,代码行数:5,代码来源:mappings.py

示例9: delete_search_index

# 需要导入模块: from arches.app.search.search_engine_factory import SearchEngineFactory [as 别名]
# 或者: from arches.app.search.search_engine_factory.SearchEngineFactory import delete_index [as 别名]
def delete_search_index():
    se = SearchEngineFactory().create()
    se.delete_index(index='resource')
开发者ID:fargeo,项目名称:arches,代码行数:5,代码来源:mappings.py

示例10: setUpClass

# 需要导入模块: from arches.app.search.search_engine_factory import SearchEngineFactory [as 别名]
# 或者: from arches.app.search.search_engine_factory.SearchEngineFactory import delete_index [as 别名]
    def setUpClass(cls):
        se = SearchEngineFactory().create()
        se.delete_index(index='strings')
        se.delete_index(index='resource')

        cls.client = Client()
        cls.client.login(username='admin', password='admin')

        models.ResourceInstance.objects.all().delete()
        with open(os.path.join('tests/fixtures/resource_graphs/Search Test Model.json'), 'rU') as f:
            archesfile = JSONDeserializer().deserialize(f)
        ResourceGraphImporter(archesfile['graph'])

        cls.search_model_graphid = 'e503a445-fa5f-11e6-afa8-14109fd34195'
        cls.search_model_cultural_period_nodeid = '7a182580-fa60-11e6-96d1-14109fd34195'
        cls.search_model_creation_date_nodeid = '1c1d05f5-fa60-11e6-887f-14109fd34195'
        cls.search_model_name_nodeid = '2fe14de3-fa61-11e6-897b-14109fd34195'

        # Add a concept that defines a min and max date
        concept = {
            "id": "00000000-0000-0000-0000-000000000001",
            "legacyoid": "ARCHES",
            "nodetype": "ConceptScheme",
            "values": [],
            "subconcepts": [
                {
                    "values": [
                        {
                            "value": "ANP TEST",
                            "language": "en-US",
                            "category": "label",
                            "type": "prefLabel",
                            "id": "",
                            "conceptid": ""
                        },
                        {
                            "value": "1950",
                            "language": "en-US",
                            "category": "note",
                            "type": "min_year",
                            "id": "",
                            "conceptid": ""
                        },
                        {
                            "value": "1980",
                            "language": "en-US",
                            "category": "note",
                            "type": "max_year",
                            "id": "",
                            "conceptid": ""
                        }
                    ],
                    "relationshiptype": "hasTopConcept",
                    "nodetype": "Concept",
                    "id": "",
                    "legacyoid": "",
                    "subconcepts": [],
                    "parentconcepts": [],
                    "relatedconcepts": []
                }
            ]
        }

        post_data = JSONSerializer().serialize(concept)
        content_type = 'application/x-www-form-urlencoded'
        response = cls.client.post(reverse('concept', kwargs={'conceptid':'00000000-0000-0000-0000-000000000001'}), post_data, content_type)
        response_json = json.loads(response.content)
        valueid = response_json['subconcepts'][0]['values'][0]['id']

        # add resource instance with only a cultural period defined
        cls.cultural_period_resource = Resource(graph_id=cls.search_model_graphid)
        tile = Tile(data={cls.search_model_cultural_period_nodeid: [valueid]},nodegroup_id=cls.search_model_cultural_period_nodeid)
        cls.cultural_period_resource.tiles.append(tile)
        cls.cultural_period_resource.save()

        # add resource instance with only a creation date defined
        cls.date_resource = Resource(graph_id=cls.search_model_graphid)
        tile = Tile(data={cls.search_model_creation_date_nodeid: '1941-01-01'},nodegroup_id=cls.search_model_creation_date_nodeid)
        cls.date_resource.tiles.append(tile)
        tile = Tile(data={cls.search_model_name_nodeid: 'testing 123'},nodegroup_id=cls.search_model_name_nodeid)
        cls.date_resource.tiles.append(tile)
        cls.date_resource.save()

        # add resource instance with with no dates or periods defined
        cls.name_resource = Resource(graph_id=cls.search_model_graphid)
        tile = Tile(data={cls.search_model_name_nodeid: 'some test name'},nodegroup_id=cls.search_model_name_nodeid)
        cls.name_resource.tiles.append(tile)
        cls.name_resource.save()

        # add delay to allow for indexes to be updated
        time.sleep(1)
开发者ID:azerbini,项目名称:eamena,代码行数:93,代码来源:search_tests.py

示例11: tearDownClass

# 需要导入模块: from arches.app.search.search_engine_factory import SearchEngineFactory [as 别名]
# 或者: from arches.app.search.search_engine_factory.SearchEngineFactory import delete_index [as 别名]
 def tearDownClass(cls):
     se = SearchEngineFactory().create()
     se.delete_index(index="concept_labels")
     se.delete_index(index="term")
     se.create_index(index="concept_labels")
     se.create_index(index="term")
开发者ID:archesproject,项目名称:arches,代码行数:8,代码来源:concept_import_tests.py

示例12: setUpClass

# 需要导入模块: from arches.app.search.search_engine_factory import SearchEngineFactory [as 别名]
# 或者: from arches.app.search.search_engine_factory.SearchEngineFactory import delete_index [as 别名]
    def setUpClass(cls):
        se = SearchEngineFactory().create()
        se.delete_index(index='strings')
        se.delete_index(index='resource')


        cls.client = Client()
        cls.client.login(username='admin', password='admin')

        models.ResourceInstance.objects.all().delete()
        with open(os.path.join('tests/fixtures/resource_graphs/Search Test Model.json'), 'rU') as f:
            archesfile = JSONDeserializer().deserialize(f)
        ResourceGraphImporter(archesfile['graph'])

        cls.search_model_graphid = 'e503a445-fa5f-11e6-afa8-14109fd34195'
        cls.search_model_cultural_period_nodeid = '7a182580-fa60-11e6-96d1-14109fd34195'
        cls.search_model_creation_date_nodeid = '1c1d05f5-fa60-11e6-887f-14109fd34195'
        cls.search_model_destruction_date_nodeid = 'e771b8a1-65fe-11e7-9163-14109fd34195'
        cls.search_model_name_nodeid = '2fe14de3-fa61-11e6-897b-14109fd34195'
        cls.search_model_sensitive_info_nodeid = '57446fae-65ff-11e7-b63a-14109fd34195'
        cls.search_model_geom_nodeid = '3ebc6785-fa61-11e6-8c85-14109fd34195'

        cls.user = User.objects.create_user('test', '[email protected]', 'test')
        cls.user.save()
        cls.user.groups.add(Group.objects.get(name='Guest'))

        nodegroup = models.NodeGroup.objects.get(pk=cls.search_model_destruction_date_nodeid)
        assign_perm('no_access_to_nodegroup', cls.user, nodegroup)

        # Add a concept that defines a min and max date
        concept = {
            "id": "00000000-0000-0000-0000-000000000001",
            "legacyoid": "ARCHES",
            "nodetype": "ConceptScheme",
            "values": [],
            "subconcepts": [
                {
                    "values": [
                        {
                            "value": "Mock concept",
                            "language": "en-US",
                            "category": "label",
                            "type": "prefLabel",
                            "id": "",
                            "conceptid": ""
                        },
                        {
                            "value": "1950",
                            "language": "en-US",
                            "category": "note",
                            "type": "min_year",
                            "id": "",
                            "conceptid": ""
                        },
                        {
                            "value": "1980",
                            "language": "en-US",
                            "category": "note",
                            "type": "max_year",
                            "id": "",
                            "conceptid": ""
                        }
                    ],
                    "relationshiptype": "hasTopConcept",
                    "nodetype": "Concept",
                    "id": "",
                    "legacyoid": "",
                    "subconcepts": [],
                    "parentconcepts": [],
                    "relatedconcepts": []
                }
            ]
        }

        post_data = JSONSerializer().serialize(concept)
        content_type = 'application/x-www-form-urlencoded'
        response = cls.client.post(reverse('concept', kwargs={'conceptid':'00000000-0000-0000-0000-000000000001'}), post_data, content_type)
        response_json = json.loads(response.content)
        valueid = response_json['subconcepts'][0]['values'][0]['id']
        cls.conceptid = response_json['subconcepts'][0]['id']

        # add resource instance with only a cultural period defined
        cls.cultural_period_resource = Resource(graph_id=cls.search_model_graphid)
        tile = Tile(data={cls.search_model_cultural_period_nodeid: [valueid]},nodegroup_id=cls.search_model_cultural_period_nodeid)
        cls.cultural_period_resource.tiles.append(tile)
        cls.cultural_period_resource.save()

        # add resource instance with a creation and destruction date defined
        cls.date_resource = Resource(graph_id=cls.search_model_graphid)
        tile = Tile(data={cls.search_model_creation_date_nodeid: '1941-01-01'},nodegroup_id=cls.search_model_creation_date_nodeid)
        cls.date_resource.tiles.append(tile)
        tile = Tile(data={cls.search_model_destruction_date_nodeid: '1948-01-01'},nodegroup_id=cls.search_model_destruction_date_nodeid)
        cls.date_resource.tiles.append(tile)
        tile = Tile(data={cls.search_model_name_nodeid: 'testing 123'},nodegroup_id=cls.search_model_name_nodeid)
        cls.date_resource.tiles.append(tile)
        cls.date_resource.save()

        # add resource instance with a creation date and a cultural period defined
        cls.date_and_cultural_period_resource = Resource(graph_id=cls.search_model_graphid)
        tile = Tile(data={cls.search_model_creation_date_nodeid: '1942-01-01'},nodegroup_id=cls.search_model_creation_date_nodeid)
#.........这里部分代码省略.........
开发者ID:fargeo,项目名称:arches,代码行数:103,代码来源:search_tests.py

示例13: delete_index

# 需要导入模块: from arches.app.search.search_engine_factory import SearchEngineFactory [as 别名]
# 或者: from arches.app.search.search_engine_factory.SearchEngineFactory import delete_index [as 别名]
def delete_index(index=None):
    se = SearchEngineFactory().create()
    se.delete_index(index=index)
    pass
开发者ID:oswalpalash,项目名称:arches,代码行数:6,代码来源:entity_model_tests.py

示例14: setUpModule

# 需要导入模块: from arches.app.search.search_engine_factory import SearchEngineFactory [as 别名]
# 或者: from arches.app.search.search_engine_factory.SearchEngineFactory import delete_index [as 别名]
def setUpModule():
    #pass
    se = SearchEngineFactory().create()
    se.delete_index(index='test')
开发者ID:1000camels,项目名称:arches,代码行数:6,代码来源:search_tests.py

示例15: tearDownModule

# 需要导入模块: from arches.app.search.search_engine_factory import SearchEngineFactory [as 别名]
# 或者: from arches.app.search.search_engine_factory.SearchEngineFactory import delete_index [as 别名]
def tearDownModule():
    se = SearchEngineFactory().create()
    se.delete_index(index='strings')
    se.delete_index(index='resource')
开发者ID:azerbini,项目名称:eamena,代码行数:6,代码来源:base_test.py


注:本文中的arches.app.search.search_engine_factory.SearchEngineFactory.delete_index方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。