I need help: Search query for single custom object array with words and values sorted decending

I am currently troubled by creating an elasticsearch query that searches firstly the "customPayload", sort by the word value. It is currently enough if it only works with single word search terms. If possible I also want to search through the "head" text for word occurences, matching the search term, added after the sorted "customPayload" search.

So the expected Result after a search for 'text' should be

[{head: 'some text', ...}, {head: 'some of the first words [...]', ...}] 

If someone could help me building the first part of it, Id be really happy, as well as for some advice how the second part could be implemented.

The Json structure before posted onto elasticsearch (for clearence):

{
    "DummyIndex": {
        "DummyType": [
            {
                "index": "0aske13kah24",
                "head":'some of the first words to have a search onto the persons name',
                "text": 'sometimes you need a little bit of confidence to function correctly and write a good text.',
                "customPayload": [{word: "text", value: 0.7}, {word: "function", value: 1.9}]
            },
            {
                "head": 'some test',
                "text": 'some text to test the function',
                "customPayload": [{word: "text", value: 1}, {word: "function", value: 0.9}]
            }
        ]
    }
}

The elastic search typing

{
    "dummyindex": {
        "mappings": {
            "dummytype": {
                "properties": {
                    "head": {
                        "type": "text",
                        "fields": {
                            "keyword": {
                                "type": "keyword",
                                "ignore_above": 256
                            }
                        }
                    },
                    "payload": {
                        "properties": {
                            "value": {
                                "type": "float"
                            },
                            "word": {
                                "type": "text",
                                "fields": {
                                    "keyword": {
                                        "type": "keyword",
                                        "ignore_above": 256
                                    }
                                }
                            }
                        }
                    },
                    "text": {
                        "type": "text",
                        "fields": {
                            "keyword": {
                                "type": "keyword",
                                "ignore_above": 256
                            }
                        }
                    }
                }
            }
        }
    }
}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.