Solved

Oracle TEXT search question

Posted on 2016-11-01
9
57 Views
Last Modified: 2016-11-04
Have a need for the TEXT search condition. After I indexed the column description in T1 with Oracle TEXT, I use the syntax "contains"

select count(1) from t1 where contains( lower( description), 'abcd', 1) >0;

However I got the error complaining  "lower( description)" is not indexed. I knew it was not for this, but how should I deal with this situation? If I do the following, it is fast, but it is not the way to form the sql.
 
select count(1) from t1 where contains(  description, 'abcd', 1) >0;
select count(1) from t1 where contains(  description, 'Abcd', 1) >0;
...
All combinations.


(for normal where clause:  select count(1) from t1 where lower( description) like 'abcd'; when the table is big, it is too slow)
0
Comment
Question by:jl66
  • 3
  • 2
  • 2
  • +1
9 Comments
 
LVL 10

Assisted Solution

by:HuaMinChen
HuaMinChen earned 100 total points
ID: 41869499
Try not to put lower below
select count(1) from t1 where contains( lower( description), 'abcd', 1) >0;

Open in new window


Try also instr to do the search.
0
 

Author Comment

by:jl66
ID: 41869516
In my original question, I already mentioned the query you gave, which caused ORA- error: lower( description) is not indexed.
0
 
LVL 10

Expert Comment

by:HuaMinChen
ID: 41869535
Hi,
Is the speed fine after you've removed 'lower(...)' to your query?
0
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

 
LVL 35

Accepted Solution

by:
johnsone earned 400 total points
ID: 41870027
The default behavior for a text index is case insensitive.  Unless you changed that when you created the index, there should be no need for the lower function.
0
 

Author Comment

by:jl66
ID: 41874149
I specifically made sure that I used the default one. the search result still showed the case sensitive. Thanks for info though.
0
 

Author Comment

by:jl66
ID: 41874151
Thanks.
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 41874158
You closed this before I had time to post.

It is not case sensitive.  I've used it since somewhere around version 7 before it was called Text.

Please run this test case:
drop table tab1 purge;
create table tab1(col1 varchar2(20));

insert into tab1 values('HeLlO');
insert into tab1 values('hello');
insert into tab1 values('HELLO');
commt;

create index tab1_idx on tab1(col1) indextype is ctxsys.context;

select * from tab1 where contains(col1,'hello') > 0;
select * from tab1 where contains(col1,'HELLO') > 0;

Open in new window

0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 41874163
Any reason you accepted a post that isn't even valid syntax?
0
 
LVL 35

Expert Comment

by:johnsone
ID: 41874255
Honestly, I haven't used it since Oracle 8, before it was renamed to Text.  I did check the documentation and the BASIC_LEXER defaults still to case insensitive.

http://docs.oracle.com/database/121/CCREF/cdatadic.htm#CCREF0218

The default for mixed_case on the lexer is NO.  The AUTO_LEXER, if you are using that one, inherits the mixed_case value from the BASIC_LEXER, so it is still there and defaults to NO.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question