I would like to perform a like or regexp across several columns. These columns contain tags, keywords, etc. Something that’s the equivalent of:
sqlplus scott/tiger @myquery.sql | grep somestring
Right now I have something like
select * from foo where c1 || c2 || c3 like '%somestring%'
but I’m hoping I can get something a bit more general purpose and/or optimized. Any clues appreciated!
Have you thought about using the Concatenated Datastore feature of Oracle Text?
Oracle Text lets you create full-text indexes on multiple columns in the same table. Or at least there’s a process by which you can do this.
There’s a good example document on the Oracle site I’ve used before:
http://www.oracle.com/technology/sample_code/products/text/htdocs/concatenated_text_datastore/cdstore_readme.html
Oracle Text searches are ridiculously fast. I think I’d look at keeping separate context indexes on each individual column so that you could apply relevance and priority to each column match.
Let me know if you’d like an example and I’ll add something to the answer.
Hope this helps.