Custom Field Mapping in Solrnet

168 views
Skip to first unread message

Nimisha J

unread,
Nov 13, 2014, 9:46:48 AM11/13/14
to sol...@googlegroups.com
Hi, 

I am trying to map the custom fields in the Solrnet. But some how its failing to map the newly added fields. Can someone please assist me doing the same. 
I have marked the new fields with SolrField in the model file. 
below is the code 

  //working code start
            Startup.InitContainer();
            Startup.Init<HtmlContent>("http://localhost:8080/solr-4.10.2/");
            ISolrOperations<HtmlContent> solr = ServiceLocator.Current.GetInstance<ISolrOperations<HtmlContent>>();
            
            //Read a file.
            FileStream fileStream = System.IO.File.OpenRead(@"D:\SolrUpload\123.pdf");
            
            //Approach 1:- Adds/Updates the extracted content of a Rich Document.
            ExtractResponse response =
                solr.Extract(
                    new ExtractParameters(fileStream, "123.pdf")
                    {
                        ExtractFormat = ExtractFormat.Text,
                        ExtractOnly = false,
                        //StreamType = "text/html" //for XML files
                        StreamType = "application/pdf", //for PDF files
                        //StreamType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
                        Fields = new[] 
                            { 
                                 new ExtractField("userRole", "1")
                                 ,new ExtractField ("Tags","Tagging")
                                 , new ExtractField("comments", "New")
                                 , new ExtractField("category", "PDF Documents")
                                 , new ExtractField("popularity", "1") 
                            }
                    });
            content = response.Content;

            //code to convert the stream into string so that we can pass this content directly to the solr.Add() method.
            using(StreamReader reader = new StreamReader(fileStream, Encoding.UTF8))
            {
                content = reader.ReadToEnd();
            }

          
            solr.Commit();
            //working code end

            ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";

            return View();



am I missing any step in between... Any kind of help for this is appreciated. 

-- Nimisha J. 

Mauricio Scheffer

unread,
Nov 13, 2014, 8:09:19 PM11/13/14
to sol...@googlegroups.com
Did you add those fields to the Solr schema?


--
Mauricio

--
You received this message because you are subscribed to the Google Groups "SolrNet" group.
To unsubscribe from this group and stop receiving emails from it, send an email to solrnet+u...@googlegroups.com.
To post to this group, send email to sol...@googlegroups.com.
Visit this group at http://groups.google.com/group/solrnet.
For more options, visit https://groups.google.com/d/optout.

Nimisha J

unread,
Nov 13, 2014, 10:35:31 PM11/13/14
to sol...@googlegroups.com
Yes.... I have added those fields as well... but those are not reflecting ... :-(

Mauricio Scheffer

unread,
Nov 14, 2014, 3:01:43 AM11/14/14
to sol...@googlegroups.com
You mean the properties aren't being populated from a query result? Have you checked that the fields are configured as stored="true" in the Solr schema?


--
Mauricio
Reply all
Reply to author
Forward
0 new messages