Trim response as much as possible to save on bandwidth?

1 like 0 dislike
7 views
I've got a site search working well with Solr but I want to decrease the amount of bandwidth used as much as possible.

All I really need from the response is an array of ids and the language code - but it also sends a full response object which, amongst other things I don't need, appears to duplicate the results again. Is there any way to edit the configuration files to not return the search_api_solr_response object, and possible the remove the 'fields' and 'score' from the results too?

I m using this with Drupal/Search API/Search API Solr if it makes any difference.

Currently the response looks like the below output:

    Array
    (
        [results] => Array
            (
                [3478/en] => Array
                    (
                        [id] => 3478/en
                        [score] => 0.08070879
                        [fields] => Array
                            (
                                [search_api_id] => 3478/en
                                [search_api_relevance] => 0.08070879
                            )
    
                    )
    
                [3544/en] => Array
                    (
                        [id] => 3544/en
                        [score] => 0.042019945
                        [fields] => Array
                            (
                                [search_api_id] => 3544/en
                                [search_api_relevance] => 0.042019945
                            )
    
                    )
    
                [5351/en] => Array
                    (
                        [id] => 5351/en
                        [score] => 0.042019945
                        [fields] => Array
                            (
                                [search_api_id] => 5351/en
                                [search_api_relevance] => 0.042019945
                            )
    
                    )
    
                [3435/en] => Array
                    (
                        [id] => 3435/en
                        [score] => 0.036767453
                        [fields] => Array
                            (
                                [search_api_id] => 3435/en
                                [search_api_relevance] => 0.036767453
                            )
    
                    )
    
            )
    
        [search_api_solr_response] => stdClass Object
            (
                [request] => GET /solr/website/select?fl=item_id%2Cscore&qf=tm_body%24value%5E1.0&qf=tm_field_introduction%5E1.0&qf=tm_listing_category_title%5E1.0&qf=tm_listing_region_title%5E1.0&qf=tm_title_field%5E13.0&qf=tm_title_ngram%5E21.0&fq=ss_type%3A%22listing%22&fq=ss_search_api_language%3A%22en%22&fq=index_id%3A%22default_multilingual_node_index%22&fq=hash%3Acabrkl&start=0&rows=75&sort=score%20desc&wt=json&json.nl=map&q=%22circus%22 HTTP/1.0
    Authorization: Basic amVubmlmZXIuY2hpbkB3aGl6cGEuY29tOlcxOTc1
    User-Agent: Agent
    Host: Host
    
    
                [data] => {"response":{"numFound":4,"start":0,"maxScore":0.08070879,"docs":[{"item_id":"3478/en","score":0.08070879},{"item_id":"3544/en","score":0.042019945},{"item_id":"5351/en","score":0.042019945},{"item_id":"3435/en","score":0.036767453}]}}
    
                [protocol] => HTTP/1.1
                [status_message] => OK
                [headers] => Array
                    (
                        [date] => Mon, 03 Jul 2017 09:22:41 GMT
                        [server] => Jetty(9.2.4.v20141103)
                        [content-type] => text/plain; charset=UTF-8
                        [vary] => Accept-Encoding
                        [connection] => close
                    )
    
                [code] => 200
                [response] => stdClass Object
                    (
                        [numFound] => 4
                        [start] => 0
                        [maxScore] => 0.08070879
                        [docs] => Array
                            (
                                [0] => stdClass Object
                                    (
                                        [item_id] => 3478/en
                                        [score] => 0.08070879
                                    )
    
                                [1] => stdClass Object
                                    (
                                        [item_id] => 3544/en
                                        [score] => 0.042019945
                                    )
    
                                [2] => stdClass Object
                                    (
                                        [item_id] => 5351/en
                                        [score] => 0.042019945
                                    )
    
                                [3] => stdClass Object
                                    (
                                        [item_id] => 3435/en
                                        [score] => 0.036767453
                                    )
    
                            )
    
                    )
    
            )
    
        [result count] => 4
        [performance] => Array
            (
                [complete] => 1.3094301223755
                [preprocessing] => 0.010263919830322
                [execution] => 1.2335319519043
                [postprocessing] => 0.00068306922912598
                [hooks] => 0.064917087554932
            )
    
    )
asked Jul 4 in Shared Solr Cloud by mrchristoph (180 points)

1 Answer

0 like 0 dislike

If you are using solr with drupal, then, it means that the Drupal module decides what data it requests from the SOLR service, in order to be able to correctly display your search results.

In all other cases (say you're developing your own search engine app), you can request certain fields from solr when performing your solr request.
You can learn more about how to request certain fields here.

Hope this helps.

answered Jul 4 by admin (2,870 points)
...