title: Space characters inside Oracle's Contains() function
body: <p>I needed to use Oracle 11g's Contains() function to search some exact text contained in some field typed by the user. I was asked not to use the 'like' operator.</p>
  
  <p>According to the <a href="http://docs.oracle.com/cd/B28359_01/text.111/b28304/cqspcl.htm" rel="nofollow">Oracle documentation</a>, for everything to work you need to:</p>
  
  <ul>
  <li>Double <code>}</code> characters</li>
  <li>Put the whole input between <code>{}</code></li>
  </ul>
  
  <p>This works in most cases except for a few ones. Below it a test case:</p>
  
  <pre><code>create table theme
    (name varchar2(300 char) not null);
  
  insert into theme (name)
  values ('a');
  
  insert into theme (name)
  values ('b');
  
  insert into theme (name)
  values ('a or b');
  
  insert into theme (name)
  values ('Pdz344_1_b');
  
  create index name_index on theme(name) indextype is ctxsys.context;
  </code></pre>
  
  <p>If the <code>'or'</code> operator was interpreted, I would get all four results, which is hopefully not the case.  Now if I run the following, I would expect is to only find <code>'a or b'</code>.</p>
  
  <pre><code>select * from theme
  where contains(name, '{a or b}')&gt;0;
  </code></pre>
  
  <p>However I also get <code>'Pdz344_1_b'</code>. But there's no <code>'a'</code>, <code>'o'</code> not <code>'r'</code> and I find it very surprising that this text is matched. Is there something I don't get about contains()'s syntax?</p>