[TYPO3-Solr] Indexing custom table with nested relations

Samir Rachidi sr at plusb.de
Thu Mar 13 09:55:05 CET 2014


Hello Typo3-Community,

I have an existing Extbase-Extension and i am trying to connect it to an Apache Solr-Instance. I am using the Extension tx_solr and i just want to index a custom table, but I have a problem with nested relations.

I have three models, which are structured like this:

Item
+title:string
+subtitle:string
+jobs: ObjectStorage<Job>

Job
+title:string
+person:Person

Person
+name:string
+lastname:string

There is an 1:n relation from "Item" to "Job" and an 1:1 relation from "Job" to "Person"

My Solr-Configuration is something like this:

plugin.tx_solr.index {
  queue {
          tx_myExt_domain_model_item = 1
          tx_myExt_domain_model_item {
                  fields {      
                        itemTitle_stringS = title
			itemSubtitle_stringS = subtitle
#...
  			itemJobs_stringM = SOLR_RELATION
  			itemJobs_stringM {
  				localField = jobs
  				relationTableSortingField = sorting
  				multiValue = 1
  			}
#...
			content = ...
			url = ...
		}
          }
  }
}

So, the Solr-Configuration works for any simple Properties (of type integer, string etc.). Even 1:n-relations work, but I just get the value of only one field of the relation-object inside the resulting document. This is fine, because I just need only the value of the label-field (e.g. there is a Tag-Relation with only one field called ‚name'). 

But the problem is the 1:n-relation to the the model "Job", which has a 1:1-relation to the model "Person". With this configuration, the indexed Solr-documents will have the persons name for each related "Job"-object. What I need is the name- and the firstname-property of the "Job"-object, but I don't know how to implement this. I think my most promising idea was something like this:


itemJobs_stringM = SOLR_CONTENT
itemJobs_stringM {
    table = tx_myExt_domain_model_job
    select {
      pidInList = 3
      recursive = 100
      selectFields = tx_myExt_domain_model_job.role as role, tx_myExt_domain_model_person.firstname as firstname, tx_myExt_domain_model_person.name as name
      leftjoin = tx_myExt_domain_model_person ON (tx_myExt_domain_model_job.person = tx_myExt_domain_model_person.uid)
      where = tx_myExt_domain_model_job.item = {field:uid}
    }                                                
}

But this didn't work, because of the uid of the Item-object. Is there any possibility to do this or do I need to modify the Solr-Extension for this?

Btw: I'm working with Typo3 4.5




More information about the TYPO3-project-solr mailing list