# Multi-valued field indexing

**URL:** <https://community.neo4j.com/t/multi-valued-field-indexing/3873>\
**Category:** Cypher\
**Created:** [December 16, 2018, 6:03pm UTC](https://community.neo4j.com/t/multi-valued-field-indexing/3873 "2018-12-16T18:03:26Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![dbeaumon](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/dbeaumon/32/1071_2.png) [@dbeaumon](https://community.neo4j.com/u/dbeaumon)\
**Post date:** [December 16, 2018, 6:03pm UTC](https://community.neo4j.com/t/multi-valued-field-indexing/3873/1 "2018-12-16T18:03:26Z")

</div>

Is it possible to apply an index to a list of (string) values, so that you can efficiently look up "all nodes with a list property that contains X".

I have tried creating the index, and adding a list of strings, but any cypher search I do either returns nothing, or the profile shows the results are obtained via a label scan and not the index.

If it is possible:  
a) Does the CREATE INDEX statement need to do anything special?  
b) What does the MATCH statement look like?

Thanks,

Dave

---

<div class="post-metadata">

**Author:** ![andrew\_bowman](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/andrew_bowman/32/73_2.png) [@andrew\_bowman](https://community.neo4j.com/u/andrew_bowman)\
**Post date:** [December 17, 2018, 1:22pm UTC](https://community.neo4j.com/t/multi-valued-field-indexing/3873/2 "2018-12-17T13:22:32Z")

</div>

Currently this kind of lookup isn't supported with schema indexes. We would advise remodeling these as connected nodes to your main node.

For example, if you had something like:

```auto
(:Sentence {id:12345, words:['sphynx', 'of', 'black', 'quartz', 'judge', 'my', 'vow']})

```

We would advise you to remodel such that:

```auto
(:Sentence {id:12345})-[:HAS_WORD]->(:Word {word:'sphynx'})

```

and so forth with a separate :Word node per word, and an index on :Word(word) for quick lookup.

Your :Word nodes would be reused with other :Sentence nodes so you could find similar sentences with the same words:

```auto
MATCH (w:Word)<-[:HAS_WORD]-(s:Sentence)
WHERE w.word = 'quartz'
RETURN s

```

---

<div class="post-metadata">

**Author:** ![michael.hunger](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/michael.hunger/32/27377_2.png) [@michael.hunger](https://community.neo4j.com/u/michael.hunger)\
**Post date:** [December 18, 2018, 10:03am UTC](https://community.neo4j.com/t/multi-valued-field-indexing/3873/3 "2018-12-18T10:03:28Z")

</div>

Array indexes only find the full array.  
You can use a manual index via APOC for that (which indexes each array entry),  
or better the new fulltext index for 3.5.

---

<div class="post-metadata">

**Author:** ![dbeaumon](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/dbeaumon/32/1071_2.png) [@dbeaumon](https://community.neo4j.com/u/dbeaumon)\
**Post date:** [December 20, 2018, 4:46pm UTC](https://community.neo4j.com/t/multi-valued-field-indexing/3873/4 "2018-12-20T16:46:04Z")

</div>

Thanks. APOC was going to be plan B, but the additional manual index maintenance was a headache I didn't really want for a solution to an edge case that I'm hoping will never happen. I'm going to give 3.5 a try - it's about time I took a look.

I assume that the Neo4JRule TestRule code (Java) for 3.5 supports this new indexing for my testing entertainment?

---

<div class="post-metadata">

**Author:** ![michael.hunger](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/michael.hunger/32/27377_2.png) [@michael.hunger](https://community.neo4j.com/u/michael.hunger)\
**Post date:** [January 8, 2019, 9:18am UTC](https://community.neo4j.com/t/multi-valued-field-indexing/3873/5 "2019-01-08T09:18:06Z")

</div>

The new indexes are managed via procedures, so i don't see why not.

---

<div class="post-metadata">

**Author:** ![clem](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/clem/32/4364_2.png) [@clem](https://community.neo4j.com/u/clem)\
**Post date:** [December 29, 2020, 7:20pm UTC](https://community.neo4j.com/t/multi-valued-field-indexing/3873/7 "2020-12-29T19:20:08Z")

</div>

I tried searching but it's not clear to me if APOC full text search can work on an **list of strings**. It would be nice if it did.

E.g. If I have a person with nicknames, can I do an APOC full text index and search on the list of nicknames? (I understand the built-in indexing property indexing won't work.)

```auto
CREATE (p:Person {name:"Elizabeth", nicknames: [
  "Lizzy", "Liz", "Beth", "Betsy"]})

```

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![michael.hunger](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/michael.hunger/32/27377_2.png) [@michael.hunger](https://community.neo4j.com/u/michael.hunger)\
**Post date:** [December 30, 2020, 11:00pm UTC](https://community.neo4j.com/t/multi-valued-field-indexing/3873/8 "2020-12-30T23:00:04Z")

</div>

The old 3.x indexes supported multi-value arrays/lists as properties. None of the current indexes do. There are a number of feature requests for it but nothing has been decided yet.

---

<div class="post-metadata">

**Author:** ![clem](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/clem/32/4364_2.png) [@clem](https://community.neo4j.com/u/clem)\
**Post date:** [December 30, 2020, 11:08pm UTC](https://community.neo4j.com/t/multi-valued-field-indexing/3873/9 "2020-12-30T23:08:26Z")

</div>

Is that true for both standard indexing and full text indexing?

Thanks.

---

<div class="post-metadata">

**Author:** ![michael.hunger](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/michael.hunger/32/27377_2.png) [@michael.hunger](https://community.neo4j.com/u/michael.hunger)\
**Post date:** [January 23, 2021, 2:22pm UTC](https://community.neo4j.com/t/multi-valued-field-indexing/3873/10 "2021-01-23T14:22:27Z")

</div>

Yes, true for both types of indexes

---

<div class="post-metadata">

**Author:** ![frederico.braga](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/frederico.braga/32/5404_2.png) [@frederico.braga](https://community.neo4j.com/u/frederico.braga)\
**Post date:** [April 2, 2021, 9:10am UTC](https://community.neo4j.com/t/multi-valued-field-indexing/3873/11 "2021-04-02T09:10:22Z")

</div>

Thanks, any updates on these feature requests?

---

<div class="post-metadata">

**Author:** ![andrew\_bowman](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/andrew_bowman/32/73_2.png) [@andrew\_bowman](https://community.neo4j.com/u/andrew_bowman)\
**Post date:** [April 2, 2021, 8:22pm UTC](https://community.neo4j.com/t/multi-valued-field-indexing/3873/12 "2021-04-02T20:22:13Z")

</div>

No changes at this time on this one, though there are other index changes coming down the pipeline.
