How to run raw SQL to get "OR" results?

Hi I am using Omeka 2.2.2.

With the advanced search feature, it seems the default operator for multiple terms is AND, and I cannot search for element text containing “xxxx” OR “yyyy”.

The only thing I can think of is a raw query like this to get the record IDs then build a loop using set_items_for_loop():

SELECT `omeka_items`.`id`
FROM `omeka_items` 
JOIN `omeka_element_texts` 
ON `omeka_items`.`id` = `omeka_element_texts`.`record_id` 
WHERE `omeka_element_texts`.`text` = "XXXX" OR `omeka_element_texts`.`text` = "YYYY" 
ORDER BY `omeka_items`.`id`
limit 0, 20

Question is, how do I fire this query?
Or even, is it an overkill? Is there simpler ways to achieve an “OR” search?

Thanks in advance.

For the simplest approach, you can wait for the next release of Omeka, which has that option added to the search page. That should be out in less than two months. You can also grab the current code from github, or cherry pick in the commit that adds the change.

1 Like

Hi Patrick, thank you for your quick response pointing to the right direction, and many thanks, Omeka team, for the beautiful code.

Hi @hktang,
Where can I find the query used by Omeka to populate search content?
Thanks, Darp

Hi @patrickmj,
Is there a way to remove pagination in search result page?
I tried but, I am getting only limited records on the page rather than all records contains search text.
I am thinking of a possible way to remove ‘limit’ param on search query if is there any?
I was unable to locate query, can you give some pointers?
Thank you, Darp

The easiest thing to do is to change the “Records per page” setting under Appearance -> Settings to something very large. However, that will affect all the browse pages, so that might not be what you want.

A tiny plugin that uses the search_text_browse_per_page filter would also let you change the limit to something very large.