Esempio n. 1
0
def _ownership_search(request):
    query = request.GET.get("q", "")

    if query:
        return paginated_search(request, ElasticOwnership.search().query(
            "match", _all={"query": query, "minimum_should_match": "2"}
        ))

    return paginated_search(
        request, ElasticOwnership.search().query("match_all"))
Esempio n. 2
0
def _ownership_search(request):
    query = request.GET.get("q", "")

    fields_to_search = [
        "owner", "asset", "ownership_ground", "ownership_form", "share",
        "comment", "mortgage_charge", "mortgage_details",
        "mortgage_charge_subjects", "mortgage_holder", "mortgage_mortgagor",
        "mortgage_guarantor", "mortgage_other_persons"
    ]

    if query:
        ownerships = ElasticOwnership.search().query("multi_match",
                                                     query=query,
                                                     operator="and",
                                                     fields=fields_to_search)

        if ownerships.count() == 0:
            # PLAN B, PLAN B
            ownerships = ElasticOwnership.search().query(
                "multi_match",
                query=query,
                operator="or",
                minimum_should_match="2",
                fields=fields_to_search)
    else:
        ownerships = ElasticOwnership.search().query("match_all")

    return paginated_search(request, ownerships)
Esempio n. 3
0
def _ownership_search(request):
    query = request.GET.get("q", "")

    fields_to_search = [
        "owner", "asset", "ownership_ground", "ownership_form", "share",
        "comment", "mortgage_charge", "mortgage_details",
        "mortgage_charge_subjects", "mortgage_holder", "mortgage_mortgagor",
        "mortgage_guarantor", "mortgage_other_persons"]

    if query:
        ownerships = ElasticOwnership.search().query(
            "multi_match", query=query, operator="and",
            fields=fields_to_search
        )

        if ownerships.count() == 0:
            # PLAN B, PLAN B
            ownerships = ElasticOwnership.search().query(
                "multi_match", query=query,
                operator="or",
                minimum_should_match="2",
                fields=fields_to_search
            )
    else:
        ownerships = ElasticOwnership.search().query("match_all")

    return paginated_search(request, ownerships)
Esempio n. 4
0
def office(request, office_name):
    search = Declaration.search()\
        .filter('term', general__post__office=office_name)

    return {
        'query': office_name,
        'results': paginated_search(request, search)
    }
Esempio n. 5
0
def region_office(request, region_name, office_name):
    search = Declaration.search()\
        .filter('term', general__post__region=region_name)\
        .filter('term', general__post__office=office_name)

    return {
        'query': office_name,
        'results': paginated_search(request, search),
    }
Esempio n. 6
0
def search(request):
    query = request.GET.get("q", "")
    search = Declaration.search()
    if query:
        search = search.query("match", _all=query)
    else:
        search = search.query('match_all')

    return {"query": query, "results": paginated_search(request, search)}
Esempio n. 7
0
def search(request):
    query = request.GET.get("q", "")
    search = Declaration.search()
    if query:
        search = search.query("match", _all=query)
    else:
        search = search.query('match_all')

    return {
        "query": query,
        "results": paginated_search(request, search)
    }
Esempio n. 8
0
def search(request):
    query = request.GET.get("q", "")
    search = Declaration.search()
    if query:
        search = search.query("match",
                              _all={
                                  "query": query,
                                  "operator": "and"
                              })

        if not search.count():
            search = Declaration.search().query("match",
                                                _all={
                                                    "query": query,
                                                    "operator": "or",
                                                    "minimum_should_match": "2"
                                                })
    else:
        search = search.query('match_all')

    return {"query": query, "results": paginated_search(request, search)}
Esempio n. 9
0
def _addresses_search(request):
    query = request.GET.get("q", "")

    if query:
        addresses = ElasticAddress.search().query(
            "match", _all={"query": query, "operator": "and"}
        )

        if addresses.count() == 0:
            # PLAN B, PLAN B
            addresses = ElasticAddress.search().query(
                "match", _all={
                    "query": query,
                    "operator": "or",
                    "minimum_should_match": "2"
                },
            )
    else:
        addresses = ElasticAddress.search().query("match_all")

    return paginated_search(request, addresses)
Esempio n. 10
0
def search(request):
    query = request.GET.get("q", "")
    search = Declaration.search()
    if query:
        search = search.query(
            "match", _all={"query": query, "operator": "and"})

        if not search.count():
            search = Declaration.search().query(
                "match",
                _all={
                    "query": query,
                    "operator": "or",
                    "minimum_should_match": "2"
                }
            )
    else:
        search = search.query('match_all')

    return {
        "query": query,
        "results": paginated_search(request, search)
    }
Esempio n. 11
0
def _addresses_search(request):
    query = request.GET.get("q", "")

    if query:
        addresses = ElasticAddress.search().query("match",
                                                  _all={
                                                      "query": query,
                                                      "operator": "and"
                                                  })

        if addresses.count() == 0:
            # PLAN B, PLAN B
            addresses = ElasticAddress.search().query(
                "match",
                _all={
                    "query": query,
                    "operator": "or",
                    "minimum_should_match": "2"
                },
            )
    else:
        addresses = ElasticAddress.search().query("match_all")

    return paginated_search(request, addresses)