Solr proximity search return no result - solr

The query I'm using is q=name:"william test bay"~2.
Schema.xml has the following:
<field name="name" type="text_en" indexed="true" stored="true"/>
The follow two is the response I want to return but in fact no result is returned:
"response": {
"numFound": 2,
"start": 0,
"docs": [
{
"id": "3",
"name": "william bay",
"_version_": 1561163645757423600
},
{
"id": "4",
"name": "william bay photography",
"_version_": 1561163645757423600
}
]
}
I'd like to know why. For example, I want to match "william test bay" to "william bay". I thought the edit distance is 1, just delete term "test"? In fact even name:"william test bay"~1000 doesn't work.
Currently using Solr 4.10.3. This is the one used by Cloudera Search so I couldn't upgrade it.

Proximity Searches
In Proximity all the phrase query keyword has to be present in document. In your case test keyword is not present. That's why you are not getting any result.
A proximity search looks for terms that are within a specific distance from one another.The distance referred to here is the number of term movements needed to match the specified phrase.But not to delete the keyword from the phrase query.
[Example]
text : william bay photography
query : william photography
To match above query distance has to be one. Because only one word has to be moved for search string to matched with the text.
q:"william photography"~1

You could try to use Query: q=name:(william test bay)

Related

How to display the individual score for search results in solr?

I am testing Solr 9.0 with this tutorial:
https://solr.apache.org/guide/solr/latest/getting-started/tutorial-techproducts.html
I used this query:
http://localhost:8983/solr/techproducts/select?q=cat:electronics&fl=name
In the results displayed, it only gives a masScore. How to display each individual score for each result?
"response": {
"numFound": 12,
"start": 0,
"maxScore": 0.5244061,
"numFoundExact": true,
"docs": [
{
"name": "Samsung SpinPoint P120 SP2514N - hard drive - 250 GB - ATA-133"
},
{
"name": "Maxtor DiamondMax 11 - hard drive - 500 GB - SATA-300"
},
{
"name": "Belkin Mobile Power Cord for iPod w/ Dock"
},
You can read individual document scores as an additional field in the results via the fl (Field List) parameter.
The fl parameter limits the information included in a query response
to a specified list of fields. The fields must be either stored="true"
or docValues="true".
The field list can be specified as a space-separated or
comma-separated list of field names. The string score can be used to
indicate that the score of each document for the particular query
should be returned as a field. The wildcard character * selects all
stored fields in the document.
http://localhost:8983/solr/techproducts/select?q=cat:electronics&fl=name,score

Boost document in solr where document's field contains some value

I have documets in solr in below format
{ "documents": [ {
"custom_string_New Arrival": "false",
"custom_string_Brand Name": "GB",
"custom_string_Product Name": "GB GB Girls Big Girls 7%2D16 Flutter%2DSleeve Jumpsuit",
"score": 11.223517,
"id": "67012"
},
{
"custom_string_New Arrival": "false",
"custom_string_Brand Name": "Lucy Paris",
"custom_string_Product Name": "Lucy Paris Knit Camille Sleeveless Belted Jumpsuit",
"score": 11.223517,
"id": "50097"
} ] }
I want boost a document whose custom_string_Product Name contains "Paris Knit"
I am creating a solr query with query parameter
bq=(custom_string_Product\ Name:(*Paris Knit*))^5000
I am expecting that the document with id= 50097 should come at the top, but i am not getting the expected result.
But if if do
bq=(custom_string_Product\ Name:(*Knit*))^5000
then I get the correct response.
the difference is only that in first query there is a space in between the search term.
When you're using wildcard queries (i.e. a * is present), most analysis is skipped (except those that are multitermaware, which are a few filters). In this case it simply doesn't work because there is no tokens matching Paris Knit - the tokens are probably stored as paris and knit (and not as one single token).
You can use either a string type field or a KeywordTokenizer for the field type - the KeywordTokenizer allows you to add a LowercaseFilter as well, so that your boosts becomes case insensitive.

Include fields other than count in azure facet results?

While faceting azure search returns the count for each facet field by default.How do I also get other searchable fields for every facet?
Ex When I facet for area , I want something like this.(description is a searchable field)
{
"area": [
{
"count": 1,
"description": "Acrylics",
"value": "ACR"
},
{
"count": 1,
"description": "Power",
"value": "POW"
}
]
}
Can someone please help with the extra parameters I need to send in the query?
Unfortunately there is no good way to do this as there is no direct support for nested faceting in Azure search (you can upvote it here). To achieve the result you want you would need to store the data together as a composite value as described by this workaround.

Get results from Solr facets

I am pretty new to Solr, so I don't know if what I'd like to achieve is actually feasible or not.
Currently, I am querying my Solr to retrieve the amount of results that match the conditions in several facet queries.
For example:
localhost:8082/solr/dict/select?q=*:*&rows=0&wt=json&indent=true&facet=true&facet.query=dict1:"#tiger#"&facet.query=dict1:"#lion#"
With this kind of query, I am getting the count of Solr docs containing "tiger" and the count of those cointaining "lion", in field "dict1":
{
"responseHeader": {
"status": 0,
"QTime": 239,
"params": {
"facet.query": [
"dict1:\"#tiger#\"",
"dict1:\"#lion#\""
],
"q": "*:*",
"indent": "true",
"rows": "0",
"wt": "json",
"facet": "true"
}
},
"response": {
"numFound": 37278987,
"start": 0,
"docs": [ ]
},
"facet_counts": {
"facet_queries": {
"dict1:\"#tiger#\"": 6,
"dict1:\"#lion#\"": 10
},
[...]
}
}
The thing is that now I need to get also some results for each facet, aside as the count (for example, three results for "tiger" and three more for "lion")
I have read some similar questions (Solr Facetting - Showing First 10 results and Other or SOLR - Querying Facets, return N results per Facet ) , but none of their answers seems to work for me, maybe because I am doing the facets on all docs (q=*:*).
Any help will be welcome :)
As per mailing list, what about simply using grouping ?
solr/hotels/search?q=*%3A*&wt=json&indent=true&group=true&group.query=query1&group.query=query2&group.limit=3 [1]
Is this ok for you? This returns 2 groups (1 per query) with the related count and max number of documents.
[1] https://cwiki.apache.org/confluence/display/solr/Result+Grouping

Solr facet substring search

Imagine I have the following facets:
Speakers: [Mike Thompson, Thomas Wilkinson, Sally Jeffers]
Venues: [Weill Thomas Medical Center, BB&R Medical Associates, KLR Thompson]
Solr seems to allow a &facet.prefix=Thom where I can get the facets that START with "Thom" and that will return "Speaker: Thomas Wilkinson" but no others.
How can I do the equivalent of &facet.substring=Thom which will return Mike Thompson and Weill Thomas....
I tried &facet.query=Thom but that doesnt seem to work at all.
Thanks
It is not possible to be sure as you did not provide your full query string, but it may be that the facet is not returning Weill Thomas in facet results because you are only specifying facet.field=speakers in your query, and Weill Thomas is actually in the venues field. You would require second facet.field=venues parameter in your search query to retrieve those.
Facet prefix is only used to filter results once the search is already done, so don't use that parameter for searching purposes. Check this question: SOLR facet search by prefix with results highlighting
Edit based on comment:
You don't necessarily need to filter results returned by faceting after the fact, just make sure that only the facets you want match the original query. The facets that were not part of the search query will have 0 occurances on them if you return all facets. You can then set facet.mincount=1 to only get facets that are found within the search results. Here's an example that I mocked up with test data:
q=*Thom*&rows=0&df=speakers&wt=json&indent=true&facet=true&facet.field=speakers&facet.field=venues&facet.mincount=1&json.nl=map
And the response from Solr:
"responseHeader": {
"status": 0,
"QTime": 3,
"params": {
"q": "*Thom*",
"df": "speakers",
"facet.field": [
"speakers",
"venues"
],
"json.nl": "map",
"indent": "true",
"facet.mincount": "1",
"rows": "0",
"wt": "json",
"facet": "true",
"_": "1431772681445"
}
},
"response": {
"numFound": 2,
"start": 0,
"docs": []
},
"facet_counts": {
"facet_queries": {},
"facet_fields": {
"speakers": {
"Mark Thomas": 1,
"Thomas Moore": 1
},
"venues": {
"Weill Thomas": 1
}
},
"facet_dates": {},
"facet_ranges": {},
"facet_intervals": {},
"facet_heatmaps": {}
}
Just wanted to point out a caveat of the proposed solution (i.e. which is to basically just do your facet substring query as the main Solr query, and then the facet values will be what you want). This won't work correctly for multi-valued fields. For example, if a document had 3 values for speaker of "Mark Thomas", "Fred Jones", "John Doe", then the query 'q=*Thom*' would return as facets "Fred Jones" and "John Doe", in addition to "Mark Thomas", and this would not be the desired result (i.e. "Fred Jones" and "John Doe" should not be returned). So for single-valued fields this solution could work, but for multi-valued fields you would probably have to write an intermediary web service that would filter out the non-matches (like "Fred Jones" and "John Doe"). Solr should really add a facet.substring parameter that would work like the facet.prefix parameter, but do substring filtering on the facet values instead of prefix filtering.

Resources