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

Allow value_count to support text fields #5569

Open
katlim-br opened this issue Nov 28, 2024 · 1 comment
Open

Allow value_count to support text fields #5569

katlim-br opened this issue Nov 28, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@katlim-br
Copy link

katlim-br commented Nov 28, 2024

Is your feature request related to a problem? Please describe.
We want to obtain the number of field occurrences for a query search.

For example:

If I send the following query to filter the results and also get aggregations for them (how many times the field is present in the results)

{
    "query": "xyz",
    "max_hits": 3,
    "aggs": {
        "hostname": {
            "value_count": { "field": "hostname" }
        },
        "memory": {
            "value_count": { "field": "memory" }
        }
    }
}

The current result is:

{
    "data": {
        "num_hits": 132268,
        "hits": [
            {
                "hostname": "pc1",
                "memory": 4294967296,
            },
            {
                "hostname": "pc2",
                "memory": 4294967296,
            },
            {
                "hostname": "pc3",
                "memory": 4294967296,
            },
        ],
        "aggregations": {
            "hostname": {
                "value": 0
            },
            "memory": {
                "value": 4234 (whatever value)
            }
        }
    }
}

"memory" works because it is a number.
"hostname" doesn't work because it is a text field.

Describe the solution you'd like
The result should be

        "aggregations": {
            "hostname": {
                "value": 53454
            },
            "memory": {
                "value": 4234
            }
        }

Where hostname can be counted on.

Describe alternatives you've considered
Create an extra "fields" field with the list of fields in the object, and then run a "terms" aggregation query. This probably works, but it will increase the network traffic through our Kafka pipeline and the index sizes.

Additional context
We need the count to be for all values even if repeated.
The aggregation counts must correspond to the query provided.

@katlim-br katlim-br added the enhancement New feature or request label Nov 28, 2024
@rdettai
Copy link
Contributor

rdettai commented Nov 28, 2024

The fix in Tantivy: quickwit-oss/tantivy#2547

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

No branches or pull requests

2 participants