# Pin ES Documents at specific position

**URL:** https://discuss.elastic.co/t/pin-es-documents-at-specific-position/264386
**Category:** Elasticsearch
**Created:** [February 16, 2021, 7:21am UTC](https://discuss.elastic.co/t/pin-es-documents-at-specific-position/264386 "2021-02-16T07:21:39Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Venkata\_Naresh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/venkata_naresh/32/51355_2.png) [@Venkata\_Naresh](https://discuss.elastic.co/u/Venkata_Naresh)
#### Post date: [February 16, 2021, 7:21am UTC](https://discuss.elastic.co/t/pin-es-documents-at-specific-position/264386/1 "2021-02-16T07:21:39Z")

</div>

I have some documents in ES Index in which I have a requirement to pin the documents at specific index positions irrespective of their score based on the ids.

I tried pinned query but it fetching and pinning the documents on top. But I want to place the pinned items at specific positions.

**My Data:**

```auto
    {
      "docs": [
        {
          "_id": 1,
          "name": "jack",
          "score": 40
        },
        {
          "_id": 4,
          "name": "taylor",
          "score": 35
        },
        {
          "_id": 3,
          "name": "mark",
          "score": 20
        },
        {
          "_id": 2,
          "name": "ryan",
          "score": 10
        }
      ]
    }

```

Suppose I have pinned documents at index 2 and 4 based on its id values and the final response should be like below

**Response:**

```auto
      "docs": [
        {
          "_id": 1,
          "name": "jack",
          "score": 40
        },
        {
          "_id": 2,
          "name": "ryan",
          "score": 10
        },
        {
          "_id": 3,
          "name": "mark",
          "score": 20
        },
        {
          "_id": 4,
          "name": "taylor",
          "score": 35
        }
      ]
    }

```

Can someone please add some insights and inputs to solve this requirement.

Thanks& Regards.

---

<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: [March 16, 2021, 7:22am UTC](https://discuss.elastic.co/t/pin-es-documents-at-specific-position/264386/2 "2021-03-16T07:22:24Z")

</div>

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