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


Python search.WikiDocumentType类代码示例

本文整理汇总了Python中kuma.wiki.search.WikiDocumentType的典型用法代码示例。如果您正苦于以下问题:Python WikiDocumentType类的具体用法?Python WikiDocumentType怎么用?Python WikiDocumentType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_excerpt

 def test_excerpt(self):
     search = WikiDocumentType.search()
     search = search.query("match", summary="CSS")
     search = search.highlight(*WikiDocumentType.excerpt_fields)
     result = search.execute()
     serializer = DocumentSerializer(result, many=True)
     eq_(serializer.data[0]["excerpt"], u"A <em>CSS</em> article")
开发者ID:30mps,项目名称:kuma,代码行数:7,代码来源:test_serializers.py

示例2: test_excerpt

 def test_excerpt(self):
     search = WikiDocumentType.search()
     search = search.query('match', summary='CSS')
     search = search.highlight(*WikiDocumentType.excerpt_fields)
     result = search.execute()
     data = DocumentSerializer(result, many=True).data
     eq_(data[0]['excerpt'], u'A <em>CSS</em> article')
开发者ID:Osmose,项目名称:kuma,代码行数:7,代码来源:test_serializers.py

示例3: test_current_locale_results

 def test_current_locale_results(self):
     self.refresh()
     results = (WikiDocumentType.search()
                                .query(query.Match(title='article') |
                                       query.Match(content='article'))
                                .filter('term', locale='en-US'))
     for doc in results.execute():
         eq_('en-US', doc.locale)
开发者ID:MatonAnthony,项目名称:kuma,代码行数:8,代码来源:test_types.py

示例4: delete_if_exists

 def delete_if_exists(self):
     es = WikiDocumentType.get_connection()
     try:
         es.indices.delete(self.prefixed_name)
     except NotFoundError:
         # Can ignore this since it indicates the index doesn't exist
         # and therefore there's nothing to delete.
         pass
开发者ID:jamonation,项目名称:kuma,代码行数:8,代码来源:models.py

示例5: test_get_excerpt_uses_summary

 def test_get_excerpt_uses_summary(self):
     self.refresh()
     results = WikiDocumentType.search().query('match', content='audio')
     ok_(results.count() > 0)
     for doc in results.execute():
         excerpt = doc.get_excerpt()
         ok_('the word for tough things' in excerpt)
         ok_('extra content' not in excerpt)
开发者ID:MatonAnthony,项目名称:kuma,代码行数:8,代码来源:test_types.py

示例6: test_get_excerpt_strips_html

 def test_get_excerpt_strips_html(self):
     self.refresh()
     results = WikiDocumentType.search().query('match', content='audio')
     ok_(results.count() > 0)
     for doc in results.execute():
         excerpt = doc.get_excerpt()
         ok_('audio' in excerpt)
         ok_('<strong>' not in excerpt)
开发者ID:MatonAnthony,项目名称:kuma,代码行数:8,代码来源:test_types.py

示例7: test_base_search

def test_base_search(db):
    '''WikiDocumentType.search() searches all documents by default.'''
    search = WikiDocumentType.search()
    expected = {
        'query': {
            'match_all': {}
        }
    }
    assert search.to_dict() == expected
开发者ID:Elchi3,项目名称:kuma,代码行数:9,代码来源:test_filters.py

示例8: handle

    def handle(self, *args, **options):
        logging.basicConfig(level=logging.INFO)

        percent = options['percent']
        if not 1 <= percent <= 100:
            raise CommandError('percent should be between 1 and 100')

        message = WikiDocumentType.reindex_all(options['chunk_size'],
                                               percent=percent)
        self.stdout.write(unicode(message) + '\n')
开发者ID:15ramky,项目名称:kuma,代码行数:10,代码来源:reindex.py

示例9: pre_delete_handler

def pre_delete_handler(instance, **kwargs):
    if not settings.ES_LIVE_INDEX:
        return

    doc = instance
    current_index = Index.objects.get_current()

    if WikiDocumentType.should_update(doc):
        unindex_documents.delay([doc.pk], current_index.pk)
    else:
        log.info('Ignoring wiki document %r while updating search index',
                 doc.pk, exc_info=True)
开发者ID:Elchi3,项目名称:kuma,代码行数:12,代码来源:signal_handlers.py

示例10: test_document_serializer

    def test_document_serializer(self):
        search = WikiDocumentType.search()
        result = search.execute()
        doc_serializer = DocumentSerializer(result, many=True)
        list_data = doc_serializer.data
        eq_(len(list_data), 7)
        ok_(isinstance(list_data, list))
        ok_(1 in [data['id'] for data in list_data])

        doc_serializer = DocumentSerializer(result[0], many=False)
        dict_data = doc_serializer.data
        ok_(isinstance(dict_data, dict))
        eq_(dict_data['id'], result[0].id)
开发者ID:Osmose,项目名称:kuma,代码行数:13,代码来源:test_serializers.py

示例11: mock_search

def mock_search(mock_elasticsearch):
    '''Mock WikiDocumentType.search() for a fake Elasticsearch and index.'''
    patcher_get_conn = mock.patch(
        'kuma.wiki.search.connections.get_connection',
        return_value=mock_elasticsearch)
    patcher_get_index = mock.patch(
        'kuma.wiki.search.WikiDocumentType.get_index',
        return_value='mdn-test')
    patcher_get_conn.start()
    patcher_get_index.start()
    yield WikiDocumentType.search()
    patcher_get_index.stop()
    patcher_get_conn.stop()
开发者ID:Elchi3,项目名称:kuma,代码行数:13,代码来源:test_filters.py

示例12: pre_delete_handler

def pre_delete_handler(**kwargs):
    if not settings.ES_LIVE_INDEX or 'instance' not in kwargs:
        return

    from kuma.wiki.tasks import unindex_documents
    from .models import Index

    doc = kwargs['instance']
    current_index = Index.objects.get_current()

    if WikiDocumentType.should_update(doc):
        unindex_documents.delay([doc.pk], current_index.pk)
    else:
        log.info('Ignoring wiki document %r while updating search index',
                 doc.pk, exc_info=True)
开发者ID:caktus,项目名称:kuma,代码行数:15,代码来源:signals.py

示例13: render_done_handler

def render_done_handler(instance, **kwargs):
    if not settings.ES_LIVE_INDEX:
        return

    doc = instance
    if WikiDocumentType.should_update(doc):
        current_index = Index.objects.get_current()
        outdated = current_index.record_outdated(doc)
        if outdated:
            log.info('Found a newer index and scheduled '
                     'indexing it after promotion.')
        doc_pks = set([item.pk for item in doc.other_translations])
        doc_pks.add(doc.id)
        try:
            index_documents.delay(list(doc_pks), current_index.pk)
        except Exception:
            log.error('Search indexing task failed', exc_info=True)
    else:
        log.info('Ignoring wiki document %r while updating search index',
                 doc.id, exc_info=True)
开发者ID:Elchi3,项目名称:kuma,代码行数:20,代码来源:signal_handlers.py

示例14: render_done_handler

def render_done_handler(**kwargs):
    if not settings.ES_LIVE_INDEX or 'instance' not in kwargs:
        return

    from kuma.wiki.tasks import index_documents
    from .models import Index

    doc = kwargs['instance']
    if WikiDocumentType.should_update(doc):
        current_index = Index.objects.get_current()
        outdated = current_index.record_outdated(doc)
        if outdated:
            log.info('Found a newer index and scheduled '
                     'indexing it after promotion.')
        doc_pks = set(doc.other_translations.values_list('pk', flat=True))
        doc_pks.add(doc.id)
        try:
            index_documents.delay(list(doc_pks), current_index.pk)
        except:
            log.error('Search indexing task failed', exc_info=True)
    else:
        log.info('Ignoring wiki document %r while updating search index',
                 doc.id, exc_info=True)
开发者ID:iakshay,项目名称:kuma,代码行数:23,代码来源:signals.py

示例15: get_queryset

 def get_queryset(self):
     return WikiDocumentType.search()
开发者ID:15ramky,项目名称:kuma,代码行数:2,代码来源:views.py


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