Search

Wow, that was quick!

If I go to:

/symphony/extension/elasticsearch/reindex/pages/1/

I get:

{"pagination":{"total-pages":2,"total-entries":0,"remaining-pages":1,"next-page":2}}

Hmm, yes, that's not very helpful indeed.. :)

I am 100% sure I had the same issue, but I can not remember how I fixed it or what it was... Is there anything in the logs that could be a pointer?

Unfortunately nothing to do with indexing or log failures is being written to the main log (manifest/logs/main).

@creativedutchmen, perhaps you'd like to push your changes to the symphonists repo? I've started pushing fixes there for various things (password/translation errors so far)

@brendo I'd love to, but I haven't had the time to properly clean up the code - I've made a bit of a mess...

I have a section called Structure: Pages and the ElasticSearch extension mapping is not recognizing my section.

Here's my files in my mappings folder…

events.json (this is recognized)
events.php (this is recognized)
structure-pages.json (NOT recognized)
structure-pages.php (NOT recognized)

here is my structure-pages.json file…

{
    "structure-pages": {
        "properties": {
            "name": {
                "type" : "multi_field",
                "store": "yes",
                "fields": {
                    "name": {"type" : "string"},
                    "raw" : {"type" : "string", "index" : "not_analyzed"},
                    "symphony_fulltext" : {"type" : "string", "analyzer": "symphony_fulltext"},
                    "symphony_autocomplete" : {"type" : "string", "analyzer": "symphony_autocomplete"}
                }
            },
            "body": {
                "type" : "multi_field",
                "store": "yes",
                "fields": {
                    "body": {"type" : "string"},
                    "raw" : {"type" : "string", "index" : "not_analyzed"},
                    "symphony_fulltext" : {"type" : "string", "analyzer": "symphony_fulltext"}
                }
            }
        }
    }
}

here is my structure-pages.php file…

<?php
class elasticsearch_structure-pages {

    public function mapData(Array $data, Entry $entry) {
        $json = array();

        $json['_boost'] = 1;

        if($data['publish-now']['value'] !== 'yes') return;

        $json['name'] = $data['name']['value'];
        $json['body'] = $data['body']['value'];
        return $json;
    }

}

Is there any reason why the Structure: Pages section is NOT showing up under my "Mappings" in Symphony?

I don’t think you’re allowed to use hyphens in PHP names. Use structure_pages

I don’t think you’re allowed to use hyphens in PHP names. Use structure_pages

That doesn't seem to be working either.

I have a section called Structure: Pages and the ElasticSearch extension mapping is not recognizing my section.

It works when you change the filenames with hyphens to underscores.

structure_pages.json structure_pages.php

here is my structure_pages.json, NOTE: use "handle" name for section structure-pages.

{
    "structure-pages": {
        "properties": {
            "name": {
                "type" : "multi_field",
                "store": "yes",
                "fields": {
                    "name": {"type" : "string"},
                    "raw" : {"type" : "string", "index" : "not_analyzed"},
                    "symphony_fulltext" : {"type" : "string", "analyzer": "symphony_fulltext"},
                    "symphony_autocomplete" : {"type" : "string", "analyzer": "symphony_autocomplete"}
                }
            },
            "body": {
                "type" : "multi_field",
                "store": "yes",
                "fields": {
                    "body": {"type" : "string"},
                    "raw" : {"type" : "string", "index" : "not_analyzed"},
                    "symphony_fulltext" : {"type" : "string", "analyzer": "symphony_fulltext"}
                }
            }
        }
    }
}

here is my structure_pages.php file, use underscore in the class name…

<?php
class elasticsearch_structure_pages {

    public function mapData(Array $data, Entry $entry) {
        $json = array();

        $json['_boost'] = 1;

        if($data['publish-now']['value'] !== 'yes') return;

        $json['name'] = $data['name']['value'];
        $json['body'] = $data['body']['value'];
        return $json;
    }

}

THIS WORKS!

Does anyone have this extension running on Symphony 2.3.x with ElasticSearch v.0.90.x?

Unfortunately, I can't seem to get this extension to work at all. Now the mapping is fine... but then I get this...

It asks for me to Rebuild Mapping before continuing. I do that, but it returns back to the same page with the same message.

http://www.screenr.com/lUFH

I am using Searchly.com ElasticSearch Service (former known as SearchBox.io). They are running ElasticSearch 0.90.5.

I don't think anything in latest Symphony or ElasticSearch would prevent this working. Your best bet would be to use a local ElasticSearch install (easy to install using homebrew) and see if that works. Maybe Searchly is preventing you creating mappings in a certain way.

The "Rebuild mappings" option in the dropdown runs this: https://github.com/symphonists/elasticsearch/blob/master/content/content.mappings.php#L24-L26

Try debugging the createType method, particularly to ensure that your JSON object is being deserialised to a PHP object properly:

https://github.com/symphonists/elasticsearch/blob/master/lib/class.elasticsearch.php#L136

Most hosted platforms do not support certain things the ES extension does, like listing all indexes. Luckily for us, these actions are not really required for this extension to work anyway.

I remember fixing the issues when looking at the qbox service, but I can't find the exact code changes anywhere - I probably reverted them after I decided they were too slow in the EU.

Brian, the issue you are having might have something to do with the fact that the mapping does not exist. Can you try to surround line 24 of the file Nick referenced with a try-catch block, like so:

case 'rebuild':
    foreach ($checked as $handle) {
            try{
                   ElasticSearch::getIndex()->getType($handle)->delete();
                }
                catch(Exception $e){}
                ElasticSearch::createType($handle);
            redirect("{$this->uri}/mappings/");
    }
    break;

I think that should get you around the creation problems.

Unfortunately, same result.

I'm getting an error about not being able to modify header information currently when trying to view ElasticSearch Mappings (on localhost, MAMP) and I have been getting it alot recently on localhost across my Symphony install. Any ideas?

Here is a Gist of the Error code

I receive the error when trying to access it from http://atheycreek.dev/symphony/extension/elasticsearch/mappings/.

Thanks for the help! I'm running MAMP on localhost with PHP 5.5.3. Same error occurs when running from PHP 5.4.19 and 5.3.27.

I'm running the integration branch of the code from symphonists/elasticsearch.

Here are my ElasticSearch mapping files:

I solved the header issue. After reading a Drupal forum post of all places they talked about the error usually being caused by things like byte-order-marks at the beginning of files. I opened my mappings files in Textmate and saw that the first PHP tag was indented. I removed the indent and voilá everything worked perfectly.

Here is my correcting teachings.php in case anyone else encounters this same issue:

https://gist.github.com/jsimcoe/7092481

I also had success installing an ElasticSearch server on our DigitalOcean droplet. Amazingly simple to setup and their SSD and RAM configs have the bandwidth to handle ES doing its thing.

I do need some help, though, has anyone been able to use ES when searching within Subsections? Many of my Sections use SSM and I haven't found out how to index data in Subsections?

Any thoughts?

I think that would take a bit of extra work on your part; I don't think the ElasticSearch Symphony extension will do a lot for you in this instance.

You would need to store all the data for your other section separately and then join them together in your query for ElasticSearch.

You would need to store all the data for your other section separately and then join them together in your query for ElasticSearch.

I would suggest the opposite — you would probably want to index your child SSM entries inside the parent entry in ElasticSearch... so long as the intention is to surface the parents in the search results when a child is matched.

Try playing with your mapping PHP file some more. var_dump the $data variable to see whether Symphony gives you the child SSM entries as a nested array of data. This is where the raw data is passed to your mapData method in your own class.

My guess is that you'll just get an array of relation_ids. For each of these you will want to do something like:

foreach($data['your-subsection-field-name']['relation_id'] as $index => $entry_id) {
  // build an entry
  $entry = EntryManager::fetch($entry_id);
  // get its section
  $section = SectionManager::fetch($entry->get('section_id'));
  // something to hold this entry's data
  $entry_data = array();
  // loop over the fields in a section
  foreach($section->fetchFields() as $field) {
    // get the data for each field for this entry
    $entry_data[$field->get('element_name')] = $entry->getData($field->get('id'));
  }
  var_dump($entry_data);
}

And then throw this stuff into your mapping for search.

Totally untested, but might put you on the right track.

Ah cool, thanks for cleaning that up Nick! It's been a while since I've touched ElasticSearch and couldn't remember how well it supported nesting data like that.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details