Hello,

I have been struggling the whole day to understand how to make the values of my CCK fields to work properly with this. I have two languages, English and Greek and from what i understand, by looking at the schema.xml all dynamic fields (which are used for the cck support) use the "text" solr field type which is for English only.

Is it possible to make these dynamic fields to be language aware ? does this functionality already exists and i simply missing it?

Looking forward to a reply

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mkalkbrenner’s picture

Assigned: Unassigned » mkalkbrenner
Category: support » bug
Status: Active » Needs review
FileSize
2.4 KB

... by looking at the schema.xml all dynamic fields (which are used for the cck support) use the "text" solr field type which is for English only.

That's not true. In your schema.xml you should find a dynamic field called ts_el_* for greek using text_el.
But I recognized that we missed to create the language specific equivalent for multiple values: tm_LANGUAGE_*.

Please try the attached patch. And don't forget to configure your search fields to use the language specific dynamic fields after you indexed some content.

arekanderu’s picture

Indeed there is a ts_el_* in my schema.xml but if i go to admin/settings/apachesolr/query-fields the language specific ts fields do not exists. For example I only see ts_cck_field_reservations: but no "Greek ts_cck_field_reservations" as i see for body

mkalkbrenner’s picture

Just to be sure:
You see ts_cck_field_reservations at admin/settings/apachesolr/query-fields but not ts_el_cck_field_reservations, right?

arekanderu’s picture

Exactly. Also, i would expect ss_ fields to have language support inside the schema but they dont. Why is that?

I can give you admin access if you want

arekanderu’s picture

I can see in schema browser that the field is there but it has no terms in it.

mkalkbrenner’s picture

ss means "string single". Strings are not handled in a language specific way like the type text. They're stored as they are. So this is correct.

The problem seems to be during indexing in these lines of code in apachesolr_multilingual.module:

      $solr = apachesolr_get_solr();
      $fields = $solr->getFields();
      foreach ($fields as $field_name => $field) {
        if (strpos($field_name, 'ts_') === 0 && isset($document->{$field_name}) && !empty($document->{$field_name})) {
          // deal with fields like cck using dynamic ts_* fields

          // search for existing language identifier at second position
          $tmp = explode('_', $field_name);
          if ($language != $tmp[1]) {
            $document->{'ts_' . $language . drupal_substr($field_name, 2)} = $document->{$field_name};
          }
        }
      }

It would be interesting to see the values of $language when $field_name is 'ts_cck_field_reservations'. Are you able to debug this?

arekanderu’s picture

Yeah i am able to debug.

It seems that $fields = $solr->getFields(); on line 135 always returns empty and the foreach loop is never executed. Any logic reason why?

mkalkbrenner’s picture

In my setup $solr->getFields() returns the fields in the index.

But as I'm thinking of it, it seems to be a race condition. If your index is empty, getFields() returns an empty result. If you re-index twice without deleting the index, it should work.

Could please verify that?

arekanderu’s picture

FileSize
28.86 KB

Didn't work unfortunately. I do see a lot of what you see on the screenshot I have attached you. Is this normal?

mkalkbrenner’s picture

FileSize
2.59 KB

Please test this patch in combination with the patch from #1.

arekanderu’s picture

I applied both patches, re-indexed but problem persists. Is there something I can do in order to help you figure this out quicker?

mkalkbrenner’s picture

Status: Needs review » Needs work

OK, we have to figure it out step by step.

I think we already solved two small issues:
1. tm_LANGUAGE_* has not been indexed in general
2. a race condition when indexing the first nodes

I already committed both patches to git branch 6.x-2.x. I suggest you directly work with this git branch instead of patching your code.

Now we to figure out why your ts_* fields are not getting copied to ts_LANGUAGE_*.

Are you sure that even with the latest code from git $fields (see #6) is still empty?

BTW which version of apachesolr modul did you install?

arekanderu’s picture

I removed everything, downloaded the git version (http://drupal.org/node/828026) and re-indexed everything and I can now see the tm_el_* fields in Search Fields but still no ts_el_* fields yet...

I am using apachesolr 6.x-2.x-dev

mkalkbrenner’s picture

Status: Needs work » Closed (works as designed)