Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Oracle TEXT search question

Posted on 2016-11-01
9
Medium Priority
?
66 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
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 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

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!

Question has a verified solution.

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

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

730 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