0

I have (among others) the follwing objects in my RavenDB:

Object1:

{
  "Texts" : [ "one two", "three four" ]
}

Object2:

{
  "Texts" : [ "one three", "two four" ]
}

I want to find all objects where a string in Texts contains both of the terms one and two.

If I index the field

from doc in docs.Objects select new { Texts }

and analyze it using the StandardAnalyzer the following query will return both Object1 and Object2 when I only want Object1:

Texts:(one AND two)

How can I solve this?

Linus
  • 3,254
  • 4
  • 22
  • 36

2 Answers2

1

Your requirement aren't really compatible. What about this document?

{
  "Texts" : [ "two one", "three four" ]
}

Do you want to find it when you search for one AND two?

If not, just do a phrase search, if yes, you can't really do what you want without using fanout.

Ayende Rahien
  • 22,925
  • 1
  • 36
  • 41
  • Yes, I'd like to find that document as well. The important thing is to be able to perform the search. The query, indexes or whatever else is needed can be adapted. – Linus Dec 11 '14 at 14:11
1

If you need it that way, you can do:

from doc in docs
from text in doc.Tests
select new { Text = text }

Note that this is a fan-out index, and if you have a lot of texts per document, that require paying attention to the resources required.

Ayende Rahien
  • 22,925
  • 1
  • 36
  • 41
  • I see, and then I'd analyze the `Text` field? (I assume `Tests` is a typo and you meant `Texts`) – Linus Dec 13 '14 at 22:13