Boa Noite a Todos. Gostaria de tirar uma dúvida sobre Oracle Text que já procurei nos manuais e não encontrei!
Gostaria de efetuar uma busca assim por exemplo:"loja de animais" quando faço esta pesquisa no google, ele me traz tudo que tem as palavras: "loja" e "animais". Sendo a palavra "de" eliminada. Sei que há uma maneira de fazer isso com Oracle Text, com um recurso chamado de stoplist e stopwords. Pois bem. Vou colocar meu teste abaixo e as observações. /***AQUI CRIEI A MINHA TABELA QUE IRÁ CONTER OS VALORES A SEREM PESQUISADOS***/ Create table bruno.teste_text(id number,texto varchar2(4000)); /***NESTA PARTE DO CÓDIGO, CRIEI UMA STOPLIST, QUE IRÁ CONTER AS STOPWORDS QUE EU DESEJO PROCURAR***/ begin ctx_ddl.create_stoplist('minhastoplist'); end; / /***AQUI ADICIONO AS STOPWORDS QUE DESEJO COLOCAR NA STOPLIST***/ begin ctx_ddl.add_stopword('minhastoplist','de'); ctx_ddl.add_stopword('minhastoplist','com'); ctx_ddl.add_stopword('minhastoplist','para'); ctx_ddl.add_stopword('minhastoplist','você'); end; /***AQUI INSERI ALGUMAS LINHAS DE TESTE***/ insert into bruno.teste_text values(1,'loja de brinquedos'); insert into bruno.teste_text values(2,'loja'); insert into bruno.teste_text values(3,'de'); insert into bruno.teste_text values(4,'brinquedos'); insert into bruno.teste_text values(5,'animais'); insert into bruno.teste_text values(6,'loja de animais'); insert into bruno.teste_text values(7,'copos'); insert into bruno.teste_text values(8,'loja de copos'); insert into bruno.teste_text values(9,'loja de cães'); insert into bruno.teste_text values(10,'cães'); insert into bruno.teste_text values(11,'caes'); insert into bruno.teste_text values(12,'loja de caes'); insert into bruno.teste_text values(13,'com'); insert into bruno.teste_text values(14,'com você'); insert into bruno.teste_text values(15,'eu com você'); insert into bruno.teste_text values(16,'eu para você'); insert into bruno.teste_text values(17,'para tu'); insert into bruno.teste_text values(18,'eu com voce'); commit; /***ESTE É MEU PRIMEIRO ÍNDICE, TIPO CONTEXT COM A STOPLIST QUE CRIEI HÁ POUCO***/ create index bruno.idx_teste_text_texto on bruno.teste_text(texto) Indextype is ctxsys.context parameters ('STOPLIST minhastoplist'); /***AQUI É QUE FALHO, QUANDO TENTO PESQUISAR A PALAVRA "LOJA DE BRINQUEDOS" GOSTARIA QUE ELE TROUXESSE TUDO QUE CONTIVÉSSE A PALAVRA "LOJA" COM A PALAVRA "BRINQUEDOS" OU QUALQUER UMA DAS DUAS! MAS, INFELIZMENTE NENHUM TESTE RETORNOU O QUE DEVERIA.***/ select * from bruno.teste_text where contains(texto,'LOJA')>0; ==> retornou 6 linhas. select * from bruno.teste_text where contains(texto,'loja')>0; ==> retornou 6 linhas select * from bruno.teste_text where contains(texto,'Loja')>0; ==> retornou 6 linhas select * from bruno.teste_text where contains(texto,'Loja de Animais')>0; ==> retornou 1, somente com a frase idêntico, nao encontrou loja ou animais ou ainda "loja animais". Neste caso, gostaria que retornasse tudo que tivésse "loja" ou "animais" select * from bruno.teste_text where contains(texto,'CãEs')>0; ==> retornou 2 linhas, ou seja, ignorou sem o acento. select * from bruno.teste_text where contains(texto,'CaEs')>0; ==> retornou 2 linhas, ou seja, ignorou com o acento select * from bruno.teste_text where contains(texto,'você')>0;==> 0, ou seja, ignorou o "você" com acento pois estava na stopword e o "eu com voce" sem acento. select * from bruno.teste_text where contains(texto,'voce')>0;==> retornou 1 linha, somente sem acento select * from bruno.teste_text where contains(texto,'com')>0; ==> retornou 0 linhas pois a palavra "com" pertence a stoplist; select * from bruno.teste_text where contains(texto,'eu')>0; ==> retornou 3 linhas select * from bruno.teste_text where contains(texto,'de')>0; ==> 0, ou seja, ignorou o "de" select * from bruno.teste_text where contains(texto,'de com para você cães')>0; ==> retornou 0 linhas. select * from bruno.teste_text where contains(texto,'animais de')>0; ==> retornou 0 linhas select * from bruno.teste_text where contains(texto,'loja animais')>0; ==> retornou 0 linhas. select * from bruno.teste_text where contains(texto,'loja or animais')>0; ==> retornou 7 linhas e não repetiu os resultados. select * from bruno.teste_text where contains(texto,'loja and animais')>0; ==> retornou 1 resultado. select * from bruno.teste_text where contains(texto,'loja animais',1)>0; ==> retornou 0 linhas select * from bruno.teste_text where contains(texto,'loja or \de or animais',1)>0; ==> retornou as linhas esperadas, ou seja, todas as que continham a palavra "loja" a palavra "de" que com o \ antes sai da stopword e com a palavra "animais". Este é o resultado que eu espero quando tento "loja de animais" ou "loja animais". select * from bruno.teste_text where contains(texto,'loja \de animais',1)>0; ==> retornou 1 linha: "loja de animais". /*** TENTEI TAMBÉM COM O MATCH***/ create index bruno.idx_teste_text_texto_m on bruno.teste_text(texto) Indextype is ctxsys.ctxrule parameters ('STOPLIST minhastoplist'); select * from bruno.teste_text where matches(texto,'loja animais')>0; ==> retornou apenas 2 linhas. nao considerou "loja de animais" select * from bruno.teste_text where matches(texto,'loja de animais')>0; ==> retornou 3 linhas, não considerou outras lojas que não sejam de animais, mas, considerou lojas e também animais. É um resultado próximo do que espero, mas, ainda há outras linhas que necessito, quando contém somente uma das palavras da frase. select * from bruno.teste_text where matches(texto,'animais')>0; ==> retornou 1 linha, não considerou loja de animais, apenas animais select * from bruno.teste_text where matches(texto,'loja')>0; ==> retornou 1 linha, não considerou loja de animais, apenas loja bom, acho que deu para entender o que quero. Há alguma maneira de fazer a pesquisa "loja de animais" retornar todas as linhas que contenham as palavras "loja", "animais" ou "loja de animais"? Ou seja, deveria retornar "loja de copos" e "loja animais" por exemplo. Abraço a todos, muito obrigado e me desculpe a caixa alta em alguns pontos, mas, coloquei somente para destacar diante do montante de informações que temos aqui.