Exemple #1
0
def _es_documents_for(locale, topics=None, products=None):
    """ES implementation of documents_for."""
    s = (DocumentMappingType.search()
         .values_dict('id', 'document_title', 'url', 'document_parent_id',
                      'document_summary')
         .filter(document_locale=locale, document_is_archived=False,
                 document_category__in=settings.IA_DEFAULT_CATEGORIES))

    for topic in topics or []:
        s = s.filter(topic=topic.slug)
    for product in products or []:
        s = s.filter(product=product.slug)

    results = s.order_by('document_display_order', '-document_recent_helpful_votes')[:100]
    results = DocumentMappingType.reshape(results)
    return results
Exemple #2
0
def _es_documents_for(locale, topics=None, products=None):
    """ES implementation of documents_for."""
    s = (DocumentMappingType.search().values_dict(
        'id', 'document_title', 'url', 'document_parent_id',
        'document_summary').filter(
            document_locale=locale,
            document_is_archived=False,
            document_category__in=settings.IA_DEFAULT_CATEGORIES))

    for topic in topics or []:
        s = s.filter(topic=topic.slug)
    for product in products or []:
        s = s.filter(product=product.slug)

    results = s.order_by('-document_recent_helpful_votes')[:100]
    results = DocumentMappingType.reshape(results)
    return results