I have tried to implement the Page and Post relation in single Solr Schema. In my use case each page has multiple posts. Page and Post fields are as follows:
Post:{post_content, owner_page_id, document_type}
Page:{page_id, document_type}
Suppose I want to query this single core for the results sorted by the total number of term frequency for specific term per each Page. First I though the following query can help me to overcome this query requirement for term "hello":
http://localhost:8983/solr/document/select?wt=json&indent=true&fl=id,name&q=*:*&group=true&group.field=owner_page_id&sort=termfreq(post_content,%27hello%27)+desc&fl=result:termfreq(post_content_text,%27hello%27),owner_page_id
But, it seems that this query returns the term frequency for single post of each page and the result is not aggregated for all of the page posts, and I am looking for the aggregate result.
I would be really grateful if somebody can help me to find the required query for my requirement.
P.S: I am using Solr 6, so JSON Facet is available for me.
Related
I have indexed few documents and now while trying to query a string from solr admin console, I am able to retrieve score value for each result retrieved by selecting field as score. But I would need to check the doc score, termfreq and other parameters considered for calculating this score which can help me to debug and understand. Can anyone help me with the possible ways? Are there any certain keywords or fields or query parameters to be specified while querying from solr admin console? Solr Version that I am using is 7.6.0.
Add debug=all (the new version of debugQuery=true) to your query string. It'll include a detailed explanation of how each part of your query contributes to the score.
Ive got following schema.xml
...
id
book
pages
genre (horror,action)
...
Is solr able to return results like this?
genre;books;pages
horror(genre);12(books);124543(pages)
action(genre);2(books);437(pages)
As you can see i want to facet over more than one field. The only thing i got work is the facet search over genre and books. But i want to have the pages as a sum also in my results.
Is Solr able to do this?
Thanks!
you can check for Solr Pivot Faceting which will provide you with hierarchy facets.
You can check if you get the pages, the summing can be done at Client side.
I have an indexed data(indexed using solrj from rdbms) having fields related to banking such as(sample):customerid, cust_name, accountno, amount, positions, pos_value, EOD_value etc
Now i want to do some searching on the data and search queries:
top 10 stocks/positions(based on stock value)
top 5 customers in decreasing order of amount in bank
which stock gained the max in a day (and the stock details)
lowest value of a stock in a particular time frame
How is it possible to query for the above in SOLR
I did read Function Query and solr Plugins but could not find much useful information...
Can we perform faceting on fields(amount,stock value etc) using some maths operations like average,sum etc...
I want to use velocity UI for the following search and what customization to its search box would be required?
Any idea???
Solr is a high performance text search engine, bases on Lucene, an excellent token matching and scoring library. This said, the kind of queries you want to run will certainly work in one way or an other with Solr, but you will have to provide Solr will all the data you want to search on. Solr will not compute min, max average values for you. It's job is it to find, rank and sort as fast as possible in previously computed values.
The fields you have listed might not give you all the details you are looking for. You will need to index some more.
If you have the data you are looking for in your index, the following queries might get the answer you are looking for or should give you a hint on how to state them.
top 10 stocks/positions
q=*:* sort=stock_value DESC rows=10
This requires that stock_value is numeric and has the latest stock price in the index.
top 5 customers
This is pretty similar.
q=*:* sort=account_value DESC rows=5
which stock gained the max in a day
You will need to index the gain per day
q=date:1995-12-31T23:59:59.999Z sort=stock_gain DESC rows=1
lowest value of a stock in a particular time frame
q=symbol:abc123 date:[1995-12-31T23:59:59.999Z TO 2007-03-06T00:00:00Z] sort=stock_value ASC rows=1
See Solr Query Syntax for Details on Date Queries
We have implemented the same thing in one of our application.
In Browse.vm under navigators "div" we have created our custom facet and when we click on that facet it recreats the url along with the parameter mentioned by "phisch" in his answer.
Example:
We have created a link called "Top 10 Stocks" in facet section on UI, and when we click it. we created a url adding parameters as
q=:&sort=stock_value DESC&rows=10
Please try this out at your end as it is working fine at my end. Sorry I cannot share the code as it is client confidential.
I am using SolrMeter to test Apache Solr search engine. The difference between Facet fields and Filter queries is not clear to me. SolrMeter tutorial lists this as an exapmle of Facet fields :
content
category
fileExtension
and this as an example of Filter queries :
category:animal
category:vegetable
categoty:vegetable price:[0 TO 10]
categoty:vegetable price:[10 TO *]
I am having a hard time wrapping my head around it. Could somebody explain by example? Can I use SolrMeter without specifying either facets or filters?
Facet fields are used to get statistics about the returned documents - specifically, for each value of that field, how many returned documents have that value for that field. So for example, if you have 10 products matching a query for "soft rug" if you facet on "origin," you might get 6 documents for "Oklahoma" and 4 for "Texas." The facet field query will give you the numbers 6 and 4.
Filter queries on the other hand are used to filter the returned results by adding another constraint. The thing to remember is that the query when used in filtering results doesn't affect the scoring or relevancy of the documents. So for example, you might search your index for a product, but you only want to return results constrained by a geographic area or something.
A facet is an field (type) of the document, so category is the field. As Ansari said, facets are used to get statistics and provide grouping capabilities. You could apply grouping on the category field to show everything vegetable as one group.
Edit: The parts about searching inside of a specific field are wrong. It will not search inside of the field only. It should be 'adding a constraint to the search' instead.
Performing a filter query of category:vegetable will search for vegetable in the category field and no other fields of the document. It is used to search just specific fields rather than every field. Sometimes you know that the term you want only is in one field so you can search just that one field.
I am trying to make search on my database using Solr, and i need to build a facet for the date of the articles(2011-6-12,2011-7-1 ..etc) and another facet for category(sport, news..etc) i built my php code using apache_solr_service and every thing is fine till now, i can do search for my data in the database, but i want to use facet to filter the articles that are created in specific date or to get the articles that belong to a specific category,
i used:
http://localhost:8888/solr/collection1/select?facet=true&facet.query=datecreated:2011-6-21&facet.mincount=1&wt=json&json.nl=map&q=ruba&start=0&rows=10
its returned all the articles that have 'ruba' word and give me the count of articles that have been created in 2011-6-21.
what i need is to get only the articles that have ruba word AND are created on 2011-6-21, i want only facet results to be returned
Try using filter query, fq=datecreated:2011-6-21 instead of facet