You have an embedded space in your keyword value, which must be escaped,
somehow. So, the actual query can be written as
article:"L. 111-5-2"
or
article:L.\ 111-5-2
The later is slightly prettier, I suppose.
I suppose you could use a wildcard:
article:L.*111-5-2
article:L.?111-5-2
If you want to make it uglier, that would be easy:
article:L.\u0020111-5-2
-- Jack Krupansky
-----Original Message-----
From: G.Long
Sent: Friday, May 04, 2012 11:48 AM
To: solr-user@lucene.apache.org
Subject: query keyword-tokenized fields with solrj
Hi :)
In schema.xml I added a custom fieldType called keyword:
<fieldType name="keyword" class="solr.TextField" positionIncrementGap="100">
<analyzer>
<tokenizer class="solr.KeywordTokenizerFactory"/>
</analyzer>
</fieldType>
and a field called article :
<field name="article" type="keyword" indexed="true" stored="true"/>
Now I would like to query this field using solrj. I'm using the
following code:
SolrQuery query = new SolrQuery("article:L. 111-5-2");
QueryResponse rsp = server.query(query);
list = rsp.getResults();
Even though there is only one entry in my index with the value "L.
111-5-2" in the field "article" I get a lot of results because the
article value is not kept as a single token. I could change my string as
"article:\\"L. 111-5-2\\"" but I was wondering if there could be any
prettier way to do that (programmatically with the solrj api) ?
Gary