Esempio n. 1
0
def index(request):
    products = Product.objects.all()
    results = Product.search()
    return render(request, 'editor/product/index.html', {
        'products': products,
        'results': results
    })
Esempio n. 2
0
def indexJSON(request):
    function_score = json.loads(request.GET.get('function_score', '[]'))
    results = Product.search(query={
        'function_score': function_score
#        'function_score': {
#            'functions': [
#                {
#                    'gauss': {
#                        'product_id': {
#                            'origin': 2,
#                            'scale': 1
#                        }
#                    }
#                }, {
#                    'gauss': {
#                        'product_id': {
#                            'origin': 0,
#                            'scale': 1
#                        }
#                    },
#                    'weight': 0.01
#                }
#            ],
#            'query': {
#                'query_string': {
#                    'query': 'variants.variant_id:3 OR variants.variant_id:2'
#                }
#            },
#            'min_score': 0
#        }
    })
    return HttpResponse(json.dumps(results), content_type="application/json")