Exemple #1
0
def _solr_search( query_dict ):
    solr = Solr()
    solr.query( query_dict )
    
    product_list = Product.objects.filter( id__in = [doc['id'] for doc in solr.docs()] )
    
    return product_list, solr.numFound()
Exemple #2
0
def _solr_search(query_dict):
    solr = Solr()
    solr.query(query_dict)

    product_list = Product.objects.filter(
        id__in=[doc['id'] for doc in solr.docs()])

    return product_list, solr.numFound()
Exemple #3
0
def search(request):
    query = request.GET.get("q", None)
    facet_query = request.GET.get("fq", '')

    if query:
        solr = Solr()
        solr.query({'q': query, 'fq': facet_query, 'fl': '*'})

        suggestion = solr.suggestion()

        return render(
            request, 'product/search.html', {
                'numFound': solr.numFound(),
                'query': query,
                'facet_query': facet_query and facet_query.split(':')[1]
                or None,
                'facets': solr.facet_fields(),
                'suggestion': suggestion,
                'solr_docs': solr.docs()
            })
    else:
        return render(request, 'product/search.html', {})
Exemple #4
0
def search(request):   
    query = request.GET.get("q", None)
    facet_query = request.GET.get("fq", '')
    
    if query:
        solr = Solr()
        solr.query({ 
            'q': query,
            'fq': facet_query,
            'fl':'*'
        })
        
        suggestion = solr.suggestion()
        
        return render(request, 'product/search.html', {
            'numFound': solr.numFound(),
            'query': query,
            'facet_query': facet_query and facet_query.split(':')[1] or None,
            'facets': solr.facet_fields(),
            'suggestion': suggestion,
            'solr_docs': solr.docs()
        })
    else:
        return render(request, 'product/search.html', {})
Exemple #5
0
def loadAllObjectPids(db):
    solr = Solr()
    solr.loadConfig('solr.cfg','prod')
    queryParams = {
        'q':'*:*',
        'fl': 'PID',
    }
#    Test small sample
    # queryParams = {
    #     'q':'RELS_EXT_isConstituentOf_uri_s:info\:fedora\/mtholyoke\:25060',
    #     'fl': 'PID',
    # }

    response = solr.query(queryParams)
    allpids = list(map(lambda x: x['PID'], response))
    for pid in allpids:
        try:
            db.cursor.execute("INSERT INTO md5s_remote VALUES ('%s', NULL, 0)" % pid)
        except sqlite3.IntegrityError as e:
            logging.warning(str(e) + ' ' + pid)
    db.connection.commit()