Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8640231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:13:45+00:00 2026-06-12T11:13:45+00:00

here is the object model.When i try to commit Product to Solr, returning unknown

  • 0

here is the object model.When i try to commit Product to Solr, returning unknown field loca

public class Product
{
    [SolrUniqueKey("id")]
    public string Id { get; set; }

    [SolrField("manu")]
    public string Manufacturer { get; set; }

    [SolrField("cat")] // cat is a multiValued field
    public ICollection<string> Categories { get; set; }

    [SolrField("price")]
    public decimal Price { get; set; }

    [SolrField("inStock")]
    public bool InStock { get; set; }

    [SolrField("loca")]
    public Location Location { set; get; }
}

public class Location
{
    [SolrField("zipcode")]
    public int Zip { set; get; }
    [SolrField("country")]
    public string Country { set; get; }
}

Is nested classes legal with solr?

why is it failing to store? when i remove [SolrField("loca")] it works fine.

how do you store such classes?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T11:13:46+00:00Added an answer on June 12, 2026 at 11:13 am

    You cannot do nested classes in Solr. So you will need to flatten the location information into the Product class. However, you can then represent it a nested class within your application, by mapping the data into/out of Solr as needed.

    As an example, update your Solr schema to store a loca_zipcode and loca_country field and then map those perhaps in a new SolrProduct class defined like the following:

    public class SolrProduct
    {
        [SolrUniqueKey("id")]
        public string Id { get; set; }
    
        [SolrField("manu")]
        public string Manufacturer { get; set; }
    
        [SolrField("cat")] // cat is a multiValued field
        public ICollection<string> Categories { get; set; }
    
        [SolrField("price")]
        public decimal Price { get; set; }
    
        [SolrField("inStock")]
        public bool InStock { get; set; }
    
        [SolrField("loca_zip")]
        public int Zip { set; get; }
    
        [SolrField("loca_country")]
        public string Country { get; set; }
    }
    

    Then you can use something like AutoMapper to map the SolrProduct flattened class to your Product class with the nested Location class.

    Another alternative would be to use dynamic fields in Solr and the dynamic mapping support in SolrNet using a Dictionary. Please see the SolrNet – Mapping section of the SolrNet wiki for more details and examples.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the code: class Class1 { private Class2 object; public Class1(Class2 obj) :
Okay here is what I'm trying to do: I have a model object that
public void test(Object obj){ //Here i have to set the values of the obj
Here is model structure: Client is User, Client can be corporate or person: class
I try implement advance on my question form here: send parameter from view-model to
Here is the code in controller: [HttpPost, ValidateInput(true)] public ActionResult Contact(ContactForm model) { if
Currently, I do serialize my model object to the SharedObject instance : try {
Here's my code: class Publisher(models.Model): name = models.CharField( max_length = 200, unique = True,
I have seen the related question here: An object with the same key already
Here is the object and global namespace for my Javascript code. Users.Cache.data = {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.