RavenDB - setting the index for the desired LuceneQuery collection

I have an object with a collection on it, and I would like to index it, but it's hard for me to figure out how to do this. The problem is that I hope to find it in the same way as a dynamic index using Lucene . This is not a complex object. A simple example:

{ Id: "object/id", Items: [ { Id: "1", Name: "One" }, { Id: "2", Name: "Two" }, { Id: "3", Name: "Three" } ] } 

And I can easily query the built-in dynamic index index raven , Lucene ;

Elements Name: "One"

It seems clean and efficient, and perfect for some of the things I need to do, but I'm trying to reproduce the behavior in my own Index and not very badly. I tell him to index the field, but he still refuses to let me call him;

 public class Things_ByItemProperties : AbstractIndexCreationTask<Thing> { public Things_ByItemProperties() { Map = things => from thing in things select new { Id = thing.Id, Items = thing.Items }; Index(n => n.Items, FieldIndexing.Analyzed); } } 

I know that I can add a specific part of the collection to the index, for example:

 public class Things_ByItemProperties : AbstractIndexCreationTask<Thing> { public Things_ByItemProperties() { Map = things => from thing in things select new { Id = thing.Id, Items = thing.Items, Items_Name = this.Select( r => r.Name) }; Index(n => n.Items, FieldIndexing.Analyzed); } } 

but this is not what i am trying to do, i was trying to tune it to query it with lucene as a dynamic index. Is it really impossible to do this?

+6
source share
1 answer

Yes, it can be done. However, this is not trivial. I suggest you take a look at the documentation . I am on the phone now, but if you have a problem with this, I can give an example tomorrow. At the same time, you can take a look at this SO answer .

+1
source

All Articles