Seems to work for me, at least at the Solr HTTP level. I just did a quick
test using the stock Solr 4.0 example.
I added a couple of mini-docs that had spaces in their ids, both leading and
trailing:
curl http://localhost:8983/solr/update?commit=true -H
'Content-type:application/csv' -d '
id,sku
abc-1,csv-sku-1
abc-2,csv-sku-2
abc-3 ,csv-sku-3
abc-4 ,csv-sku-4'
Then I queried them:
curl "http://localhost:8983/solr/select/?q=id:*abc-*&indent=true"
Response:
<result name="response" numFound="4" start="0">
<doc>
<str name="id">abc-1</str>
<str name="sku">csv-sku-1</str>
<long name="_version_">1426076902160859136</long></doc>
<doc>
<str name="id"> abc-2</str>
<str name="sku">csv-sku-2</str>
<long name="_version_">1426076902167150592</long></doc>
<doc>
<str name="id">abc-3 </str>
<str name="sku">csv-sku-3</str>
<long name="_version_">1426076902167150593</long></doc>
<doc>
<str name="id"> abc-4 </str>
<str name="sku">csv-sku-4</str>
<long name="_version_">1426076902168199168</long></doc>
</result>
All the spaces are there.
I didn't try a SolrJ query.
-- Jack Krupansky
-----Original Message-----
From: Marc Hermann
Sent: Monday, February 04, 2013 11:40 AM
To: solr-user@lucene.apache.org
Subject: Is Solr always trimming result objects ?
Hi everyone,
i am new to SOLR and I have experienced a strange behavior:
I have defined a field "name" of type "string". This field contains values
with trailing spaces such as " John".
This is intended and the space needs to "survive".
The space is in the index as I can see when using Luke.
But when I am retrieving documents from the index using :
final CommonsHttpSolrServer sorlServer =
server.connection(query.retrieveCore());
final SolrQuery solrQuery = query.getSolrQuery();
final QueryResponse response = sorlServer.query(solrQuery);
final Result result = new Result();
final SolrDocumentList documents = response.getResults();
... I don“t get the spaces ... as if all values always get a trim() before
they are returned.
Any suggestions ?
Is this a standard behavior ?
Best regards,
M. Hermann