# Elasticsearch use case implementation help

**URL:** <https://discuss.elastic.co/t/elasticsearch-use-case-implementation-help/244300>\
**Category:** Elasticsearch\
**Created:** [August 9, 2020, 10:33am UTC](https://discuss.elastic.co/t/elasticsearch-use-case-implementation-help/244300 "2020-08-09T10:33:33Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ocmvin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ocmvin/32/99006_2.png) [@ocmvin](https://discuss.elastic.co/u/ocmvin)\
**Post date:** [August 9, 2020, 10:33am UTC](https://discuss.elastic.co/t/elasticsearch-use-case-implementation-help/244300/1 "2020-08-09T10:33:33Z")

</div>

I was wondering about elastic search use case  
where as per current implementation we have to search best wholeseller for a shopkeeper where

Currently we are executing individual 3 queries agains relational DB (postgres/oracle) in order to find a nearest Wholeseller for given products by the retailers address and since the data is in millions in below mentioned tables it is taking long to search.

E.g. Retailer leaves in Newyork some area then for hist lat long system will search in all 3 types of sellers addresses.  
Note that this is just one use case and we need data from from address and their associated entities (i.e.Individual\_Wholeseller\Mall\_Wholeseller\Mall Franchisee\_Wholeseller)

ORM Relation is as follows

```
						    Address
											
				/ | \
Individual_Wholeseller Mall_Wholeseller Mall Franchisee_Wholeseller	
is_Wholeseller=Y is_WholeSeller=Y is_WholeSeller=Y

```

My Question is can it be a good solution to form an index as mentioned below and put in elastic search to implment the use case or it makes sense to index  
each query overall resultset in seperate index and query them against elastic search and union the result set of 3 queries and fulfil the requirement ?

pseudo definition of index  
wholeseller  
{  
addressid,  
lat,  
long,  
Individual\_Wholeseller\_id,  
Individual\_Wholesellers\_products  
Mall\_Wholeseller\_id,  
Mall\_Wholeseller\_products,  
Mall Franchisee\_Wholeseller\_id,  
Mall Franchisee\_Wholeseller\_products,  
has\_transport\_facility,  
is\_currently\_Active

}  
Note each entity (Individual\_Wholeseller\Mall\_Wholeseller\Mall Franchisee\_Wholeseller) here will have some more filter criterias like whether wholeseller has  
transport facility available,whether he is currently active etc and many more

---

<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 9, 2020, 10:46pm UTC](https://discuss.elastic.co/t/elasticsearch-use-case-implementation-help/244300/2 "2020-08-09T22:46:46Z")

</div>

Flattening the data is definitely the way to go.

---

<div class="post-metadata">

**Author:** ![ocmvin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ocmvin/32/99006_2.png) [@ocmvin](https://discuss.elastic.co/u/ocmvin)\
**Post date:** [August 10, 2020, 4:56am UTC](https://discuss.elastic.co/t/elasticsearch-use-case-implementation-help/244300/3 "2020-08-10T04:56:44Z")

</div>

But will there be performance impact while searching ? E.g. Searching against 2 index documents instead of 1 index for the same criteria ?

---

<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 10, 2020, 5:08am UTC](https://discuss.elastic.co/t/elasticsearch-use-case-implementation-help/244300/4 "2020-08-10T05:08:14Z")

</div>

> [@ocmvin](#):
>
> Searching against 2 index documents instead of 1 index for the same criteria ?

Indexes or documents?

---

<div class="post-metadata">

**Author:** ![ocmvin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ocmvin/32/99006_2.png) [@ocmvin](https://discuss.elastic.co/u/ocmvin)\
**Post date:** [August 10, 2020, 5:13am UTC](https://discuss.elastic.co/t/elasticsearch-use-case-implementation-help/244300/5 "2020-08-10T05:13:26Z")

</div>

**indexes** e.g. currently I am executing 3 queries (rdbms) and after analysis I thought of having 2 indexes (however many columns would redundant hence I feel to have 1 index and flatten all records in same index however some columns would be null as would not have related data ) So my question is having 2 indexes is good or 1 index to fulfil requirement is logical and fits to the principles of elastic search implementation . It would be great if you can point to link for ideal implementation principles of elastic search .

---

<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 10, 2020, 5:15am UTC](https://discuss.elastic.co/t/elasticsearch-use-case-implementation-help/244300/6 "2020-08-10T05:15:37Z")

</div>

That's not really a major concern with Elasticsearch. You need to worry more about shards.

In your case, unless you have billions of documents, it's not a concern.

---

<div class="post-metadata">

**Author:** ![ocmvin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ocmvin/32/99006_2.png) [@ocmvin](https://discuss.elastic.co/u/ocmvin)\
**Post date:** [August 10, 2020, 5:18am UTC](https://discuss.elastic.co/t/elasticsearch-use-case-implementation-help/244300/7 "2020-08-10T05:18:32Z")

</div>

Ok . Note that each rdbms entity above has millions records and would have adequate shards allocated so it is good to have 1 index and execute search against same index is good option is what I conclude.

---

<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:** [September 7, 2020, 5:18am UTC](https://discuss.elastic.co/t/elasticsearch-use-case-implementation-help/244300/8 "2020-09-07T05:18:38Z")

</div>

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