# Set Priority While Inserting Data

**URL:** <https://discuss.elastic.co/t/set-priority-while-inserting-data/56878>\
**Category:** Elasticsearch\
**Created:** [August 1, 2016, 9:57am UTC](https://discuss.elastic.co/t/set-priority-while-inserting-data/56878 "2016-08-01T09:57:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![parithiban](https://avatars.discourse-cdn.com/v4/letter/p/3bc359/32.png) [@parithiban](https://discuss.elastic.co/u/parithiban)\
**Post date:** [August 1, 2016, 9:57am UTC](https://discuss.elastic.co/t/set-priority-while-inserting-data/56878/1 "2016-08-01T09:57:58Z")

</div>

Hi All,

I have a mapping in the following format .

```
"mappings": {
        "user_profiles": {
            "properties": {
                "firstName": {
                    "properties": {                  
                        "pan": {
                            "type": "string",
                            "analyzer": "nGramAnalyzer",
                            "search_analyzer": "whitespaceAnalyzer"
                        },
                        "google": {
                            "type": "string",
                            "analyzer": "nGramAnalyzer",
                            "search_analyzer": "whitespaceAnalyzer"
                        },
                        "fb": {
                            "type": "string",
                            "analyzer": "nGramAnalyzer",
                            "search_analyzer": "whitespaceAnalyzer"
                        },
                        "twiter": {
                            "type": "string",
                            "analyzer": "nGramAnalyzer",
                            "search_analyzer": "whitespaceAnalyzer"
                        }                 
                    }               
                },
                "lastName": {
                    "properties": {                  
                        "pan": {
                            "type": "string",
                            "analyzer": "nGramAnalyzer",
                            "search_analyzer": "whitespaceAnalyzer"                    
                        },
                        "google": {
                            "type": "string",
                            "analyzer": "nGramAnalyzer",
                            "search_analyzer": "whitespaceAnalyzer"
                        },
                        "fb": { 
                            "type": "string",
                            "analyzer": "nGramAnalyzer",
                            "search_analyzer": "whitespaceAnalyzer"
                        },
                        "twiter": {
                            "type": "string",
                            "analyzer": "nGramAnalyzer",
                            "search_analyzer": "whitespaceAnalyzer"
                        }                 
                    }               
                }
            }
        }
    }

```

i will insert data into elastic search. but the thing is that while searching i need to get names in the order of precedence.

For Ex: if the user has pan.fb,twitter. I need to display the pan first [name.Is](http://name.Is) there a way to set priority to fields so top priority field will be returned?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [August 2, 2016, 10:10am UTC](https://discuss.elastic.co/t/set-priority-while-inserting-data/56878/2 "2016-08-02T10:10:07Z")

</div>

Returned when, and how?

---

<div class="post-metadata">

**Author:** ![parithiban](https://avatars.discourse-cdn.com/v4/letter/p/3bc359/32.png) [@parithiban](https://discuss.elastic.co/u/parithiban)\
**Post date:** [August 2, 2016, 1:26pm UTC](https://discuss.elastic.co/t/set-priority-while-inserting-data/56878/3 "2016-08-02T13:26:05Z")

</div>

For Ex if user first come from Facebook his first name record will be inserted as .  
{  
"firstName" : {  
"fb" : " John"  
}  
}

But if user entered the pan card details in my application the record will be inserted as for same user id above  
{  
"firstName" : {  
"pan" : " Johns"  
}  
}

Now the result look like this

{  
"firstName" : {  
"fb" : " John",  
"pan" : " Johns"  
}  
}

Now while fetching data i need to get the data in the priority which i said. While searching for the user id the result for me should return  
{  
"firstName" : " Johns"  
}

My Priority is  
1.Pan  
2.google  
3.fb  
4.twitter

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [August 2, 2016, 9:11pm UTC](https://discuss.elastic.co/t/set-priority-while-inserting-data/56878/4 "2016-08-02T21:11:53Z")

</div>

There's no way to do this in ES.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 10:30pm UTC](https://discuss.elastic.co/t/set-priority-while-inserting-data/56878/5 "2017-07-05T22:30:36Z")

</div>


