Customizing Search with Elasticsearch Query Configuration

Original Slack Thread

Hi, I’m trying to customize search. I successfully customize the examples in docs(https://datahubproject.io/docs/how/search), but I having trouble applying queries usage.

When I call elasticsearch search API(GET /dataset_datasetusagestatisticsaspect_v1/_search) like below, it works.

    "query": {
        "function_score": {
            "query": {
                "match_all": {}
            },
            "functions": [
                {
                    "script_score": {
                        "script": {
                            "source": "if (doc.containsKey('totalSqlQueries') && doc['totalSqlQueries'].size() > 0) { Math.log(1 + doc['totalSqlQueries'].value) } else { 0 }"
                        }
                    }
                }
            ]
        }
    }
}```

But I don’t know how to adjust to ELASTICSEARCH_QUERY_CUSTOM_CONFIG_FILE.
Below config file doesn’t work as what I want.

  - queryRegex: .*

    simpleQuery: true
    prefixMatchQuery: true
    exactMatchQuery: true

    functionScore:
      functions:
        - script_score:
            script:
              source:
                "if (doc.containsKey('totalSqlQueries') && doc['totalSqlQueries'].size() > 0) { Math.log(1 + doc['totalSqlQueries'].value) } else { 0 }"
          weight: 30

      score_mode: sum```

version is v0.10.2

<@UV5UEC3LN> might be able to speak to this!