# Performing semantic searches - ELSER

**URL:** https://discuss.elastic.co/t/performing-semantic-searches-elser/354568
**Category:** Elasticsearch
**Created:** [March 2, 2024, 2:11pm UTC](https://discuss.elastic.co/t/performing-semantic-searches-elser/354568 "2024-03-02T14:11:04Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![sinhapunit](https://avatars.discourse-cdn.com/v4/letter/s/ebca7d/32.png) [@sinhapunit](https://discuss.elastic.co/u/sinhapunit)
#### Post date: [March 2, 2024, 2:11pm UTC](https://discuss.elastic.co/t/performing-semantic-searches-elser/354568/1 "2024-03-02T14:11:04Z")

</div>

I am new to Elastic and I am sure my issue is very basic, if someone could give me high level pointers (or detailed instructions if they wish) it would be very helpful.

I have about 120,000 documents and each document has a property called "tx"

I want to perform semantic searches against the tx property of the document.

My questions

1. how do I setup the index and the mappings
2. how do I structure the documents for ingestion, does it need any additional property to support ELSER
3. after ingesting documents do I need to reindex?
4. how do I structure my query.

Thanks

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [March 2, 2024, 3:27pm UTC](https://discuss.elastic.co/t/performing-semantic-searches-elser/354568/2 "2024-03-02T15:27:22Z")

</div>

Welcome!

I think that a good starting page would be this one: [Tutorial: semantic search with ELSER | Elasticsearch Guide [8.12] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/semantic-search-elser.html)

---

<div class="post-metadata">

### Author: ![iulia](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/iulia/32/124658_2.png) [@iulia](https://discuss.elastic.co/u/iulia)
#### Post date: [March 2, 2024, 4:12pm UTC](https://discuss.elastic.co/t/performing-semantic-searches-elser/354568/3 "2024-03-02T16:12:50Z")

</div>

What language are you using? We have more content and examples in python - check out [the notebooks here on searchlabs](https://github.com/elastic/elasticsearch-labs/blob/main/notebooks/search/03-ELSER.ipynb)

To answer your specifics:

- If you already have your data in an index, you can create a new "target" index and use a pipeline to re-index all your documents with the new embedding values stored in a sparse-vector field.
- Alternatively, if your data comes from a different source, you can directly index it using ELSER enhancements in one go during the initial ingestion.
- For queries, you will be using the text\_expansion to perform semantic search:

```auto
"text_expansion": {
                    "ml.tokens": {
                        "model_id":".elser_model_1",
                        "model_text":"looking for a specific document in here"
                    }
                },

```

Good luck!

---

<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 30, 2024, 4:13pm UTC](https://discuss.elastic.co/t/performing-semantic-searches-elser/354568/4 "2024-03-30T16:13:14Z")

</div>

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