0

I found this article useful when indexing documents, however, how can I attach additional fields so I can pass in, say, the ID of the document in our database for use in displaying the search results? I thought by using the Fields (Of the ExtractParameters class) property I could index additional data with the document, but that doesn't seem to work or that is not its function.

Example code:

var solr = ObjectLocator.Instance.Resolve<ISolrOperations<IndexDocument>>();
            var guid = Guid.NewGuid().ToString();
            using (var fileStream = System.IO.File.OpenRead(Server.MapPath("~/files/") + "greenroof.pdf"))
            {

                var response =
                    solr.Extract(
                        new ExtractParameters(fileStream, "greenRoof1234")
                        {
                            ExtractFormat = ExtractFormat.Text,
                            ExtractOnly = false,
                            Fields = new[] { new ExtractField("field1", "value1"), new ExtractField("field2", "value2") }




                        });
            }
Community
  • 1
  • 1
DDiVita
  • 4,225
  • 5
  • 63
  • 117

3 Answers3

2

@aitchnyu is correct, passing the values via the literal.field=value method is the correct way to do this.

However, according to this post on ExtractingRequestHandler support in the SolrNet Google Group, there was a bug with the ExtractParameters.Fields not working properly. This was fixed in the 0.4.0.X versions of SolrNet. Please make sure you are using one of the latest versions of SolrNet. You can obtain that by one of the following means:

Also that discussion has some good examples of using the ExtractingRequestHandler in SolrNet as well as a workaround for adding the additional field values if you cannot upgrade to a newer version of SolrNet.

Paige Cook
  • 22,415
  • 3
  • 57
  • 68
1

This is sufficient: http://wiki.apache.org/solr/ExtractingRequestHandler#Literals .

In general use a literal.field=value while uploading.

Jesvin Jose
  • 22,498
  • 32
  • 109
  • 202
  • While this is helpful, it doesn;t tell me how to append the literal's to the Solr call using SolrNet. – DDiVita Jul 20 '12 at 10:48
0

It turned out not to be an issue with SOLRNet, but my knowledge of SOLR, in general. I needed to specify the fields in my schema. After i added the fields to my schema they were visible in my SOLR query.

DDiVita
  • 4,225
  • 5
  • 63
  • 117