# \[Feature\] dataset with an indexed column and search function

**URL:** <https://forum.inductiveautomation.com/t/feature-dataset-with-an-indexed-column-and-search-function/20261>\
**Category:** Ignition Early Access\
**Created:** [October 18, 2018, 7:13pm UTC](https://forum.inductiveautomation.com/t/feature-dataset-with-an-indexed-column-and-search-function/20261 "2018-10-18T19:13:42Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [October 18, 2018, 7:13pm UTC](https://forum.inductiveautomation.com/t/feature-dataset-with-an-indexed-column-and-search-function/20261/1 "2018-10-18T19:13:42Z")

</div>

Dataset are everywhere in Ignition.It’s very handy but sometimes we need to search a specific value in a column.  
A full scan of a large dataset can be time consuming.  
That why if we can define that one column is indexed and have a search function script based on that index.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [October 26, 2018, 3:13pm UTC](https://forum.inductiveautomation.com/t/feature-dataset-with-an-indexed-column-and-search-function/20261/2 "2018-10-26T15:13:45Z")

</div>

I’m not sure what this would look like. Is this similar to this other post: [http://forum.inductiveautomation.com/t/feature-query-ignition-dataset/20348/5](http://forum.inductiveautomation.com/t/feature-query-ignition-dataset/20348/5) , where you want a SQL-like ability to access the dataset? I’m not sure how an “index” column would otherwise help in looking at a large dataset.

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [October 26, 2018, 5:50pm UTC](https://forum.inductiveautomation.com/t/feature-dataset-with-an-indexed-column-and-search-function/20261/3 "2018-10-26T17:50:10Z")

</div>

SQL-like would be good, but SQL Query without index is not better than a loop to full-scan all the dataset.  
I think about script function like :

- system.dataset.addIndex(numColumn)
- system.dataset.find(numColumn,keyValue) =\> return the row

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 26, 2018, 8:11pm UTC](https://forum.inductiveautomation.com/t/feature-dataset-with-an-indexed-column-and-search-function/20261/4 "2018-10-26T20:11:35Z")

</div>

Have you used the .getColumnAsList() method? With a list, jython’s .index() method will give you the position (row number) of a value in that column. To go faster, load that column into a dictionary’s keys, with the values being the row number. Voilà, an index. The jython code that does these searches is as optimized as can be.

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [October 26, 2018, 8:28pm UTC](https://forum.inductiveautomation.com/t/feature-dataset-with-an-indexed-column-and-search-function/20261/5 "2018-10-26T20:28:23Z")

</div>

Yes indeed, that do the job. With the need to update the dictionnary each time you add/remove rows in the dataset. A new user type of dataset with these dictionnary update done in the background can be done, but it’s better if it was built-in in Ignition script system… there are lots of function to manipulate dataset, but nothing to seach in a dataset…  
That’s why in script we ofen prefer transfert data in dictionnary ou list to manipulate the data…and it add lots of plumbing code…

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 26, 2018, 8:32pm UTC](https://forum.inductiveautomation.com/t/feature-dataset-with-an-indexed-column-and-search-function/20261/6 "2018-10-26T20:32:03Z")

</div>

> [@mazeyrat](#):
>
> With the need to update the dictionnary each time you add/remove rows in the dataset.

Well, that's a new dataset anyways, so it'd have to be a new index. I'll see about adding a searchable dataset implementation to my Simulation Aids module.

---

<div class="post-metadata">

**Author:** ![greg.krueger](https://avatars.discourse-cdn.com/v4/letter/g/5f9b8f/32.png) [@greg.krueger](https://forum.inductiveautomation.com/u/greg.krueger)\
**Post date:** [October 29, 2019, 12:16am UTC](https://forum.inductiveautomation.com/t/feature-dataset-with-an-indexed-column-and-search-function/20261/7 "2019-10-29T00:16:08Z")

</div>

Phil,

Do you know where the .getColumnAsList() method is documented? I searched the user manual and couldn’t find a reference. Just curious how you discovered this function. Was very useful by the way!

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 29, 2019, 5:49pm UTC](https://forum.inductiveautomation.com/t/feature-dataset-with-an-indexed-column-and-search-function/20261/8 "2019-10-29T17:49:41Z")

</div>

It is a method of the BasicDataset class (Dataset is an Interface). BasicDataset is the root of pretty much all of the dataset classes that you’ll encounter in Vision.
