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 6570489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:45:45+00:00 2026-05-25T14:45:45+00:00

I am currently working on solr, in which to create a join, i need

  • 0

I am currently working on solr, in which to create a join, i need to write

http://localhost:8983/solr/select?q=category_name:cat1%20_query_:"{!dismax%20qf=category_name%20v=cat2}"

where cat1 and cat2 are the categories, in which i want my product to be, i.e all those product which have these 2 categories.

I am getting accurate results using this, by I can find how to write the same in Java using SolrJ api

wat i was doing

String myQuery = "";
myQuery += "category_name:";
myQuery += categoryNames.get(0);
myQuery += "%20_query_:\"{!dismax%20qf=category_name%20v=";
myQuery += categoryNames.get(1);
myQuery += "}\"";
query.setQuery(myQuery);

this doesnt give the soln, solr gives error

now as per page 1st ans

SolrQuery query = new SolrQuery();
query.setQuery("category_name:" + categoryNames.get(0));
String join = "";
join += "{!dismax&qf=category_name&v=";
join += categoryNames.get(1);
join += "}";
query.setParam("_query_", join);
QueryResponse response = solr.query(query);

better but still doesnt works, appends “&” which i dont want since then the output is wrong
this is wat goes to solr for processing
here results come only on basis of “cat1”, rather than AND of both

q=category_name:cat1&_query_={!dismax%26qf%3Dcategory_name%26v%3Dcat2}

3rd, tried wat page suggested in latest answer, fails miserably
this is wat goes to solr for processing
here is works like an OR operator rather than AND

q=category_name:cat1+_query_:"{!dismax+qf%3Dcategory_name+v%3Dcat2}"

PS: I needed to find solution as to how to write myQuery, Pls help, stuck at it

Its finally solved,
nested += ” AND query:\”{!dismax qf=category_name v=”;
is the solution to my problem

now the query gets processed!!
Thanks

  • 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-05-25T14:45:46+00:00Added an answer on May 25, 2026 at 2:45 pm

    After reading Nested Queries in Solr Looks like your issue has to do with passing the already encoded values, since SolrJ is going to encode them for you, and you are probably getting double encoding with your approach in the question.

    Here is a modified version without the encoding that should work:

    SolrQuery query = new SolrQuery();   
    String nested = "";
    nested += "category_name:";
    nested += categoryNames.get(0);
    nested += " AND _query_:\"{!dismax qf=category_name v=";
    nested += categoryNames.get(1);
    nested += "}\"";
    query.setQuery(nested);
    QueryResponse response = solr.query(query);
    

    You will probably need to look at your jetty or tomcat logs to see what url is actually being sent to Solr if this does not work as expected and tweak accordingly to get the desired results.

    Update: Modified to make the query option be an AND comparison.

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

Sidebar

Related Questions

Im currently working with an API which requires we send our collection details in
Currently working in Java, i'd like to be able to select part of an
Im currently working on an app which lists a set of objects in a
I currently working on a project which uses Spree Cart and which has hence
Im currently working on a site which will contain a products catalog. I am
Im currently working on a project that requires the following. I need to be
Currently working with Oracle, but will also need a solution for MS SQL. I
I currently working on a library for the NekoVM to create a binding to
Currently working on something which uses ajax for some pagination. What I'm looking to
Im currently working on a project with pygame and am in need of being

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.