Skip to main content
Clarified question
Source Link
Rainer Feike
  • 2.6k
  • 12
  • 24

How to send a custom Solr Distance Query with SearchApi

My nodes have a geofield and my search query should find all the nodes within a range.

I've managed to create a search form against my Solr Server with views. But I want to do the request by myself (having my own form and submit method). There's a solution for D7 here: How to send a custom Solr Query using Search API Solr but none of that seems to be usable with the D8 modules.

I believe there must be something like

$result = SolrSearchService('myServer', 'myIndex')->request(['title' => 'Test']);

But I can not find anything.

The views-built search page renders a query against my Solr Server like

path=/select params={q=(phonm_rendered_item:nintendo^1+tm_title:nintendo^8)&json.nl=flat&pt=48.1371079,11.5753822&d=50&omitHeader=true&fl=ss_search_api_id,ss_search_api_language,score,fts_field_geo_koordinaten__distance:geodist()&start=0&fq=%2Bindex_id:default_solr_index+%2Bhash:ozztjn&fq={!geofilt}&rows=10&sfield=locs_field_geo_koordinaten&wt=json} 

Apparently there are some parameters responsible for the distance calculation:

  • pt=48.1371079,11.5753822 - it's where I am
  • d=50 - it's the max distance
  • field_geo_koordinaten - it's the geofield in the node
  • geodist() - the function ?

How can I render such a query with Search API?

How to send a custom Solr Query with SearchApi

I've managed to create a search form against my Solr Server with views. But I want to do the request by myself (having my own form and submit method). There's a solution for D7 here: How to send a custom Solr Query using Search API Solr but none of that seems to be usable with the D8 modules.

I believe there must be something like

$result = SolrSearchService('myServer', 'myIndex')->request(['title' => 'Test']);

But I can not find anything.

How to send a custom Solr Distance Query with SearchApi

My nodes have a geofield and my search query should find all the nodes within a range.

I've managed to create a search form against my Solr Server with views. But I want to do the request by myself (having my own form and submit method). There's a solution for D7 here: How to send a custom Solr Query using Search API Solr but none of that seems to be usable with the D8 modules.

I believe there must be something like

$result = SolrSearchService('myServer', 'myIndex')->request(['title' => 'Test']);

But I can not find anything.

The views-built search page renders a query against my Solr Server like

path=/select params={q=(phonm_rendered_item:nintendo^1+tm_title:nintendo^8)&json.nl=flat&pt=48.1371079,11.5753822&d=50&omitHeader=true&fl=ss_search_api_id,ss_search_api_language,score,fts_field_geo_koordinaten__distance:geodist()&start=0&fq=%2Bindex_id:default_solr_index+%2Bhash:ozztjn&fq={!geofilt}&rows=10&sfield=locs_field_geo_koordinaten&wt=json} 

Apparently there are some parameters responsible for the distance calculation:

  • pt=48.1371079,11.5753822 - it's where I am
  • d=50 - it's the max distance
  • field_geo_koordinaten - it's the geofield in the node
  • geodist() - the function ?

How can I render such a query with Search API?

Source Link
Rainer Feike
  • 2.6k
  • 12
  • 24

How to send a custom Solr Query with SearchApi

I've managed to create a search form against my Solr Server with views. But I want to do the request by myself (having my own form and submit method). There's a solution for D7 here: How to send a custom Solr Query using Search API Solr but none of that seems to be usable with the D8 modules.

I believe there must be something like

$result = SolrSearchService('myServer', 'myIndex')->request(['title' => 'Test']);

But I can not find anything.