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

  • SEARCH
  • Home
  • 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 8342921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:54:21+00:00 2026-06-09T05:54:21+00:00

Hello i’ve read the Solr wiki and searched here but didn’t find a solution

  • 0

Hello i’ve read the Solr wiki and searched here but didn’t find a solution for my use-case:

We’re indexing customer-data with different kind of contracts into a single document.
So each customer will result in a Solr document witth one or more different contracts.

The fields for each contract are added dynamically via import (e.g. contract_type_1_s, contract_type_2_s, …; contract_change_date_1_dt, contract_change_date_2_dt, …). So all fields with ‘2‘ are related to contract no 2.
With this the user is able to search for customers who have a contract of type one and none of type two and so on.

My use case is now to return only the fields of the contract which matched the query.

Here’s an example:

<doc>
  <field name="id">100</field>
  <field name="customer_name">paul</field>
  <field name="contract_type_1_s">inhouse</field>
  <field name="contract_change_date_1_dt">2012-09-01T00:00:00Z</field>
</doc>
<doc>
  <field name="id">101</field>
  <field name="customer_name">fred</field>
  <field name="contract_type_1_s">inhouse</field>
  <field name="contract_change_date_1_dt">2012-09-01T00:00:00Z</field>
  <field name="contract_type_2_s">external</field>
  <field name="contract_change_date_2_dt">2012-09-01T00:00:00Z</field>
</doc>
<doc>
  <field name="id">102</field>
  <field name="customer_name">karl</field>
  <field name="contract_type_1_s">external</field>
  <field name="contract_change_date_1_dt">2012-09-01T00:00:00Z</field>
  <field name="contract_type_2_s">inhouse</field>
  <field name="contract_change_date_2_dt">2012-09-01T00:00:00Z</field>
</doc>

If the user now searches for customers with contract-type ‘external’ the documents with ids 101 and 102 are in the result. Now i want to return different fields of the contract which matched the query.

In this example these should be contract_change_date_1_dt for document 102 and contract_change_date_2_dt for document 101, since contract no 1 is external in document 102 and contract no 2 is external in document 101.

Is there a way to achive this behavior with build-in components?


I know that i can find out which fields matched the query with the highlight-component.

I endet up with following resolution, but it forces me to extend Solr:

  1. Write a QParser to to identify needet fields, add them to the fl-param
  2. Do a Highlighting-Query before returning the results to the Client
  3. Iterate over all docs in result and add the fields which matched the query per doc into the result list

I Hope i made my problem clear. Any suggestions which is a good way to archive this are really appreciated.

greetings René

  • 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-09T05:54:23+00:00Added an answer on June 9, 2026 at 5:54 am

    if someone needs a similar thing 😉

    I now managed to build up my custom result list in the following way:

    Create a Custom QueryComponent (extending standard QueryComponent) to store the fields which are used in the query. In the prepare-method activate highlighting with the stored fields:

    // Making params modifieable
    ModifiableSolrParams modifiableParams = new ModifiableSolrParams(params);
    req.setParams(modifiableParams);
    modifiableParams.set(HighlightParams.FIELDS, queryFieldList);
    modifiableParams.set(HighlightParams.HIGHLIGHT, "true");
    modifiableParams.set(HighlightParams.FIELD_MATCH, "true");
    modifiableParams.set(HighlightParams.SIMPLE_PRE, "");
    modifiableParams.set(HighlightParams.SIMPLE_POST, "");
    

    Create a Custom HighlightComponent (extending standard HighlightComponent) to build the result out of the std. result. In the process-method i now get the highlight info and extract the information i need:

    NamedList<Object> rspValues = rb.rsp.getValues();
    NamedList<Object> nlHl = (NamedList<Object>) rspValues.get("highlighting");
    this.hlDocsAndFields = extractHighlightingInfo(nlHl);
    

    For that i created a custom List, which is able to count the matches per contract (how much fields of contract_X_s are in the highlighted results).

    This works fine.

    I now stuck at the response writer who resolves the document-fields himself when he builds the response 🙁

    Has annyone a suggestion on changig/customizing the response writer?

    greetings René

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

Sidebar

Related Questions

Hello! I've been programming for a long time but just started developing for android,
hello creating a custom object may be a widely published topic, but my lack
hello im am getting JS error : Uncaught SyntaxError: Unexpected identifier here <script type=text/javascript>
Hello, Im working on a solution for Android that will record calls (both out
Hello I am trying to do a SOAP request here is my code: #
Hello I am developing an application about registration of users, but when the user
hello I have WCF service with webHttpEndpointBehavior under Sitecore 6 and I use Glass
Hello, I want to put custom status bar in notification window of iphone. is
Hello I did login as a super admin in the front en of joomla
Hello all I am working on javascript jquery and svg.I want to ask a

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.