2

I have following data:

"orders":{
      "placed_orders_count":2,
      "0":{
         "order_id":"000000001",
         "order_date":"2019-03-27 14:25:03"
      },
      "1":{
         "order_id":"000000002",
         "order_date":"2019-03-27 14:25:03"
      }
   }

I want to insert all this data into Solr. I have tried:

String customerFeedJson = new Gson().toJson(customerFeedsolr.getOrders());
String solrUrl = solrServerUrl.concat(customerFeedPrefix).concat(Constants.HYPHEN).concat(String.valueOf(siteID))
                        .concat(Constants.SOLR_URL_QUERIES);
HttpEntity<String> requestEntity = new HttpEntity<String>(Arrays.asList(customerFeedJson).toString());
restTemplate.exchange(solrUrl, HttpMethod.POST, requestEntity, String.class);

But on Solr, I am only able to index "placed_orders_count":2. I have indexed orders field as:

public class CustomerFeedSolr {

    @Indexed("orders_*")
    @Field(child = true)
    private Map<String, ?> orders;
//Getters and Setters
}

Expectations:

"placed_orders_count":[2.0],
 "0":[
      "order_id":"000000001",
      "order_date":"2019-03-27 14:25:03"
  ],
  "1":[
      "order_id":"000000002",
      "order_date":"2019-03-27 14:25:03"
  ]

Actual

"placed_orders_count":[2.0]
Andrej Istomin
  • 2,527
  • 2
  • 15
  • 22
Dragon
  • 25
  • 4
  • the `@Indexed` is probably a custom annotation which you have created for your project. If you look closer though you will see that the provided `@Indexed("orders_*")` does not match with the fields which remain unindexed. So probably you need the `@Indexed("order_*")` instead – Panagiotis Bougioukos Dec 14 '22 at 16:08
  • @PanagiotisBougioukos `@Indexed` is not a custom annotation. It is provided by `Solr` for `Spring Data Solr` – Dragon Dec 14 '22 at 17:43

0 Answers0