Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Elastica / ElasticSearch


Go to End


2 Posts   1432 Views

Avatar
Vlad Belfort

Community Member, 55 Posts

25 August 2016 at 10:52pm

Edited: 26/08/2016 11:39pm

Heya,

I'm trying to set up an elastica module ( using https://github.com/heyday/silverstripe-elastica ) in order to use ElasticSearch on my site but I'm having a bit of trouble setting it up.

Following the readme I've added all the configs to a search.yml file and created a controller.

I've run build & flush and when trying to go into /dev/tasks I get an error :
Warning at elastica/src/ElasticaService.php line 53: Argument 1 passed to Heyday\Elastica\ElasticaService::__construct() must be an instance of Elastica\Client, none given (http://intranet32.local/dev/tasks)

I'm not all that sure how to resolve it; not sure what an "elastica client" is or what args I need to be passing in...

Has anyone had any success in setting up ElasticSearch? (specifically the Elastica part, search engine is up and running). Could someone run me through the setup and what worked for you, I've been through a load of modules with no luck in getting it working.

BTW - I am running SS3.4

Avatar
Vlad Belfort

Community Member, 55 Posts

26 August 2016 at 10:09pm

This is my config, anything here that needs to be amended or added?

---
Name: search
---
Heyday\Elastica\ElasticaService: # Example of customising the index config on the elastic search server (completely optional).
index_config:
analysis:
analyzer:
default :
type : custom
tokenizer : standard
filter :
- standard
- lowercase
- stemming_filter
filter:
stemming_filter:
type: snowball
language: English

---
Only:
environment: dev
---
Injector:
Elastica\Client:
constructor:
- host: localhost # hostname of the elastic search server
- port: 9200 # port number of the elastic search server

Heyday\Elastica\ElasticaService:
constructor:
- %$Elastica\Client
- name-of-index # name of the index on the elastic search server
- %$Logger # your error logger (must implement psr/log interface)
- 64MB # increases memory limit while indexing

# PageTypes

Page:
extensions:
- Heyday\Elastica\Searchable
indexed_fields: &page_defaults
- Title
- MenuTitle
- Content
- MetaDescription

SpecialPageWithAdditionalFields:
extensions:
- Heyday\Elastica\Searchable # only needed if this page does not extend the 'Page' configured above
indexed_fields:
<<: *page_defaults
- BannerHeading
- BannerCopy
- SubHeading

SpecialPageWithRelatedDataObject:
extensions:
- Heyday\Elastica\Searchable
indexed_fields:
<<: *page_defaults
- RelatedDataObjects

RelatedDataObject:
extensions:
- Heyday\Elastica\Searchable
indexed_fields:
- Title
- SomeOtherField
dependent_classes:
- SpecialPageWithRelatedDataObject # invalidates the index for SpecialPageWithRelatedDataObject when a RelatedDataObject is updated/created