Home > Mobile >  how to find word or phrase that starts with a sequence in elasticsearch?
how to find word or phrase that starts with a sequence in elasticsearch?

Time:12-22

Lets say I have these data

[
    {
        name: "Apple Company"
    },
    {
        name: "Microsoft Company"
    }
]

I want to get the query results like this:

query 1:

name: apple

result 1:

[
    {
        name: "Apple Company"
    }
]

query 2:

name: app

result 2:

[
    {
        name: "Apple Company"
    }
]

query 3:

name: apple com

result 3:

[
    {
        name: "Apple Company"
    }
]

query 4:

name: apple company

result 4:

[
    {
        name: "Apple Company"
    }
]

query 5:

name: company

result 5:

[
    {
        name: "Apple Company"
    },
    {
        name: "Microsoft Company"
    }
]

query 6:

name: ap com

result 6:

[]

How to do it in elasticsearch?

CodePudding user response:

You can use enter image description here

  • Related