nqxcode / laravel-lucene-search

Laravel 4.2, 5.* package for full-text search over Eloquent models based on ZF2 Lucene.
73 stars 28 forks source link

Add support for OR #9

Closed cmoralesweb closed 8 years ago

cmoralesweb commented 9 years ago

Some of my models have translated fields, like so:

'title-es',
'title-en',
'text-es',
'text-en'

I put them all on the index config, but I want the search to be language-dependent (if the user has Spanish selected, only results matching title-es / text-es should appear, not the ones for -en

where()accepts a single field, and if you combine a couple of where() the query runs with AND. I'd need a OR in my case.

... or perhaps there's another way that I'm missing :smile:

nqxcode commented 9 years ago

You use 'query builder' to make query and 'query builder' has no orWhere method yet. But you can use raw queries (Lucene queries) without using the 'query builder'.

For example: Search::rawQuery('field1:"value1" OR field2:"value2"')->get();

cmoralesweb commented 9 years ago

OK! :+1:

orWhere() would be a nice addition to the query builder, then.

nqxcode commented 8 years ago

Search by name OR description: Search::where(['name', 'description'], 'clock');