Multiple Fields for Prefix in ElasticSearch and auto From and Size limit

user2925077

I got 2 questions related to ElasticSearch.

1) First Question, I have this query with prefix

"must": [
        {
           "prefix": {
              "user": "John"
           }
        }
     ]

with this query, I can Prefix John with User field so it results those documents in which John is found in User field. Now how can I make this query to see if John is prefixed in either any of User or email fields.


2) Second Question, I know we can apply Size and from in ElasticSearch to limit Result but I want to know that do I have to explicitly provide Size and from every time I query in ElasticSearch to continue last result or is there any other way to let the ElasticSearch do it for me that I just query and it will give results in a series left from previous.

Alex Brasetvik

First, note that the prefix-query does not do any text analysis, so you will not be matching e.g. john with your query.

You should look into the multi_match-query which takes the options of the match-query as well. Thus, you can combine multi_match with phrase_prefix and get the best of both: matching on multiple fields, and text analysis.

Here is a runnable example you can play with: https://www.found.no/play/gist/8197442

#!/bin/bash

export ELASTICSEARCH_ENDPOINT="http://localhost:9200"

# Index documents
curl -XPOST "$ELASTICSEARCH_ENDPOINT/_bulk?refresh=true" -d '
{"index":{"_index":"play","_type":"type"}}
{"user":"John Smith","email":"[email protected]"}
{"index":{"_index":"play","_type":"type"}}
{"user":"Alice Smith","email":"[email protected]"}
'

# Do searches

curl -XPOST "$ELASTICSEARCH_ENDPOINT/_search?pretty" -d '
{
    "query": {
        "multi_match": {
            "fields": [
                "user",
                "email"
            ],
            "query": "john",
            "operator": "and",
            "type": "phrase_prefix"
        }
    }
}
'

For your second question, look into the scroll API.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Multiple Fields for Prefix in ElasticSearch and auto From and Size limit

From Dev

Elasticsearch phrase prefix query on multiple fields

From Dev

Elasticsearch: query for multiple words across multiple fields (with prefix)

From Dev

Select multiple fields from columns with distinct and limit

From Dev

Select multiple fields from columns with distinct and limit

From Dev

Elasticsearch Multiple Prefix Keywords

From Dev

ElasticSearch: is there a limit to the size of "terms" when doing a match on multiple values?

From Dev

Elasticsearch Multiple Prefix query OR Matching

From Dev

Is it possible to limit a size of an Elasticsearch index?

From Dev

ElasticSearch group by multiple fields

From Dev

Elasticsearch match multiple fields

From Dev

Search on multiple fields with Elasticsearch

From Dev

Elasticsearch multiple fields autosuggestion

From Dev

Elasticsearch match multiple fields

From Dev

Elasticsearch multiple fields OR query

From Dev

Elasticsearch how count values from multiple document fields using aggregation

From Dev

Elasticsearch how count values from multiple document fields using aggregation

From Dev

is there a size limit to individual fields in HTTP POST?

From Dev

Elasticsearch sorting with from/size

From Dev

ElasticSearch sort order for multiple fields

From Dev

Search on multiple fields with ElasticSearch with or, and operators

From Dev

ElasticSearch and searching on multiple fields in PHP

From Dev

ElasticSearch filtering on multiple fields (with aggregration)

From Dev

ElasticSearch and searching on multiple fields in PHP

From Dev

Elasticsearch sort based on multiple fields

From Dev

Django limit_choices_to for multiple fields with "or" condition

From Dev

Limit file upload size across multiple files

From Java

How to search on multiple fields of array in elasticsearch

From Dev

Elasticsearch: can't filter on multiple fields

Related Related

  1. 1

    Multiple Fields for Prefix in ElasticSearch and auto From and Size limit

  2. 2

    Elasticsearch phrase prefix query on multiple fields

  3. 3

    Elasticsearch: query for multiple words across multiple fields (with prefix)

  4. 4

    Select multiple fields from columns with distinct and limit

  5. 5

    Select multiple fields from columns with distinct and limit

  6. 6

    Elasticsearch Multiple Prefix Keywords

  7. 7

    ElasticSearch: is there a limit to the size of "terms" when doing a match on multiple values?

  8. 8

    Elasticsearch Multiple Prefix query OR Matching

  9. 9

    Is it possible to limit a size of an Elasticsearch index?

  10. 10

    ElasticSearch group by multiple fields

  11. 11

    Elasticsearch match multiple fields

  12. 12

    Search on multiple fields with Elasticsearch

  13. 13

    Elasticsearch multiple fields autosuggestion

  14. 14

    Elasticsearch match multiple fields

  15. 15

    Elasticsearch multiple fields OR query

  16. 16

    Elasticsearch how count values from multiple document fields using aggregation

  17. 17

    Elasticsearch how count values from multiple document fields using aggregation

  18. 18

    is there a size limit to individual fields in HTTP POST?

  19. 19

    Elasticsearch sorting with from/size

  20. 20

    ElasticSearch sort order for multiple fields

  21. 21

    Search on multiple fields with ElasticSearch with or, and operators

  22. 22

    ElasticSearch and searching on multiple fields in PHP

  23. 23

    ElasticSearch filtering on multiple fields (with aggregration)

  24. 24

    ElasticSearch and searching on multiple fields in PHP

  25. 25

    Elasticsearch sort based on multiple fields

  26. 26

    Django limit_choices_to for multiple fields with "or" condition

  27. 27

    Limit file upload size across multiple files

  28. 28

    How to search on multiple fields of array in elasticsearch

  29. 29

    Elasticsearch: can't filter on multiple fields

HotTag

Archive