Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for creating suggester fields with weights #2229

Open
1 of 2 tasks
landlord-matt opened this issue May 14, 2024 · 0 comments
Open
1 of 2 tasks

Add support for creating suggester fields with weights #2229

landlord-matt opened this issue May 14, 2024 · 0 comments

Comments

@landlord-matt
Copy link

landlord-matt commented May 14, 2024

What kind an issue is this?

  • Bug report. If you’ve found a bug, please provide a code snippet or test to reproduce it below.
    The easier it is to track down the bug, the faster it is solved.
  • Feature Request. Start by telling us what problem you’re trying to solve.
    Often a solution already exists! Don’t send pull requests to implement new features without
    first getting our support. Sometimes we leave features out on purpose to keep the project small.

Feature description

Setting weights for your suggester fields allow you to prioritize the suggestions returned from query (note that they can't be sorted). For the standard API, you set the weights by including a weight parameter for each document, but to my understanding this is not possible when using es-hadoop and Spark DataFrames. In Databricks I would do something like this

    (
        data.write.format("org.elasticsearch.spark.sql")
        .options(**es_conf)
        .mode("overwrite")
        .save(full_index_name)
    )

To upload to an index with this mapping

{
    "full_index_name": {
        "mappings": {
            "dynamic": "strict",
            "properties": {
                "CompanyIdentifier": {
                    "type": "keyword"
                },
                "CompanyName": {
                    "type": "completion",
                    "analyzer": "simple",
                    "preserve_separators": true,
                    "preserve_position_increments": true,
                    "max_input_length": 50
                }
            }
        }
    }
}

I tried with adding an int column called weight, but that didn't do it. I tried search for parameter in the documentation, but I couldn't find any. I haven't tried a nested field, but I doubt it works.

I guess it is not trivial what the syntax would be if you have more than one completion field either, but you'll figure something out :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant