Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Oracle TEXT search question

Posted on 2016-11-01
9
Medium Priority
?
71 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 11

Assisted Solution

by:HuaMinChen
HuaMinChen earned 400 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 11

Expert Comment

by:HuaMinChen
ID: 41869535
Hi,
Is the speed fine after you've removed 'lower(...)' to your query?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 35

Accepted Solution

by:
johnsone earned 1600 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 78

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 78

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

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 article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

824 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