Searching for the grail

Post on 08-Jun-2015

1,032 views 0 download

Tags:

description

Search facilities have become such a basic commodity in applications that it's almost taken for granted. But bundled with a framework such as Grails, you the developer are faced with some limitations and extra concerns: how well is this library developed and backed? does the library fit the framework's paradigm and how good is the support for the tool within the framework itself? This talk will provided an overview and comparison in search for a piece of the holy grail - a good search facility.

transcript

Searching For The Grail

Noam Tenne

$ whoami

Noam Tenne

Senior DeveloperSenior Developer

blog.10ne.org

@NoamTenne

github.com/noamt

http

://w

ww

.flic

kr.c

om/p

hoto

s/au

ssie

gall/

Where do we standWhere do we stand

Different data

Different shapes

Sph

inx

Tech

nolo

gies

Inc.

Sphinx

Domain

Sphinx

Domain

Model has been modified

Sphinx

Domain

Update the index

Custom

Integration

Sphinx

Domain

Update the index

Custom

Integration

Sphinx

Domain

Sphinx offline for re-index

Custom

Integration

Expected interaction

Engine

Create or update the mappings on startup

Mappings

Application

Engine

Act on persistence events

Application

Domain

Engine

Act on persistence events

Update

Documents

Application

Domain

What do we choose?What do we choose?

http

://w

ww

.flic

kr.c

om

/ph

oto

s/89

869

792@

N00

/

Searchable PluginSearchable Plugin

Uses the Compass project

To become “El

asticsearch”

http://compass-project.org

Quick and easy setup

Embedded in your application

Easier maintenance!Great for testing!

Is this

a goo

d thin

g?

Compass

ApplicationPlugin

Incremental index

static searchable = true

Mark a Domain as searchable:

    static searchable = {        except = ['field1']        field2 boost: 2.0    }

Mark a Domain as searchable while customizing the mapping:

Map domains with annotations

 def result =                              Domain.search('query')

Search using the domain static API:

 def result =                         searchableService.search('query')

Search using the introduced service:

What's the threshold?

Compass

Application

Compass

Application

Compass

Application

Horizontal growth is stifled

Compass

App1

DB

Compass

App1

DB

Compass

App2

Compass

App1

DB

Compass

App2

Compass

App3

Room

to

Grow

http

://w

ww

.flic

kr.c

om/p

hoto

s/el

will

o/

Solr PluginSolr Plugin

Backed by The Apache Software Foundation

ww

w.a

pach

e.or

ght

tp://

luce

ne.a

pach

e.or

g/so

lr

Incremental index&

Facilities of modern engines

Utilizes an external instance

Compass

ApplicationPlugin

Solr

Application

Plugin

Embedding is possible but requires tweaks

Setup is fairly simpleRequires some fumbling

Solr comes as a bundled installation with the plugin

Application

Solr

ApplicationPlugin

ApplicationPlugin

Solr

grails start­solr&

grails stop­solr

static enableSolrSearch = true

Mark a Domain as searchable:

static solrAutoIndex = true

Auto-index domain:

 def result =                          Domain.searchSolr('query')

Search using the domain static API:

 def result =                               solrService.search('query')

Search using the domain static API:

...But wait a minute

-GASP-

Can you afford to maintain it?Can you afford to maintain it?

http

://w

ww

.flic

kr.c

om

/pho

tos/

loui

sa_

catlo

ver/

I'm not dead yet!

Using Solr?Using Grails?Contribute!

(yay)

Elasticsearch PluginElasticsearch Plugin

Elasticsearch

http

://w

ww

.ela

stic

sear

ch.o

rg

All the benefits of the aforementioned(Incremental, external, actively developed)

Setting up for embedded or external is a breeze

elasticSearch {    client.mode = 'local'}

Embedded:

elasticSearch {    client.mode = 'transport'}

External (single node):

static searchable = true

Mark a Domain as searchable:

static searchable = {…                

}                    

Looks familiar?

Query closures

From the trenches

http://www.flickr.com/photos/finsam/

Not released often

Plan ahead. mappings are commitments

Keep configurations in line

Call to armsHibernate

GORM

github.com/noamt/elasticsearch­gorm­plugin

Thanks!

Any queries? (HAHAHA!)