Determine last page in Solr using cursorMark - solr

I am building an API that allows for searching on a number of fields in solr with pagination. It returns cursorMark from the solr results in the API response for users to use in their next query.
I'm following the Google AIP for pagination which requires returning a blank string when there are no more results left however Solr will keep returning the same cursor.
I'm looking for a simple solution that doesn't involve keeping state on the server or needing to make multiple requests. If I knew the position of the page in the total list of results I could determine if the page is the last, but I'm not able to access this.
Is there a simple way to achieve this?

Related

How do I use AG Grid (Server-Side Row Model) and Apollo GraphQL client, with Relay-style cursor pagination in React?

In my React application, I am using the Apollo Client, with relayStylePagination(). Our API uses the Connection pattern to provide the data.
I want to introduce AG Grid to display large sets of data and to be able to use both pagination and infinite scroll behaviour. This implies the use of a Server-Side row model in my implementation.
This has proven to be difficult. I can't find any examples of this particular setup in the wild. AG Grid's own examples using GraphQL, utilise start and end rows to build and perform the paginated requests.
I need to use cursor-based pagination to build my queries. As seen on line 105 in my test-code below, I want to update the variable after (currently set to null in order to fetch the 10 first results).
Any and all input, nudges in the right direction and/or examples on how to do this is highly appreciated.

Promise.all() does not give results separetely

I'm working on a React project where I have to make multiple API calls. So, the way I have been doing is using Promise.all(), but it returns all the results at the same time which sometimes too slow and bad for users' experience. I wonder if there is anyway that I can fetch all the APIs at the same time but still give the results separately so that I can display them in "first fetched first show" order?

How to index the landing page of many URLs using Solr?

I have a list of thousands of Web URLs (originated from bookmarks). I have a need to be able to search the landing page of these URLs. I don't need the web crawler function but I need the de-duplication function.
I'm new to solr and try to figure out the simplest way to create the index. I'm thinking about using SimplePostTool that accepts multi URLs as its parameters. However, I have difficulty understanding how to use the de-duplication with this SimplePostTool.
Is there any other method to do this indexing?
Appreciate for any hints.
Thanks.

How to add a powerful search functionality to my web app

I am building an app to browse events. The front end uses angular framework and the backend uses laravel.
How do I add a powerful search functianlity, wherein the user enter his query using an input element and I pass the same to laravel controller.
I now need to return relevant events based on the query.
As of now I am using a very basic algorithm - each word in a query is pushed into an array. Article's are discarded. Based on the length of the array, I try to match each words to some fileds in the table and return unique events.
Is there a better, faster and more efficient way of doing this.
You could use laravel-search
It has support for a few advanced search methods.
I recommend you to use Elastic search for your goals. You can find tutorial here: http://www.fullstackstanley.com/read/simple-search-with-laravel-and-elasticsearch. Also you can use good wrapper https://github.com/mmanos/laravel-search for elastic and another search engines.
Well you added the tag elasticSearch so I guess that's what you are interested in. ElasticSearch has no authentication system so the best way is to create a controller in Laravel that comunicates with elasticSearch a returns the JSON response.
A basic setup will not be hard to do, anything beyond that will need you to learn more advanced concepts of ElasticSearch.
ElasticSearch will handle the search algorithm for you, you just need to pass the value the user is searching and that's it.

Retrieve Response data from another website using cakephp

I am trying to hit the courier companies website from Controller ( e.g bluedart,fedex etc) by passing the courier tracking number and fetch status of the given tracking number.
I am using $HttpSocket->get/post to hit the webpage URL
I am able to display the response body
How can I fetch the data from the response.
Or is there any other way to achieve the same
Please help me out .
How can I fetch the data from the response.
Parse the result, either using regular expressions or the DOMDocument class and traverse it. See Parsing HTML in Cakephp as well.
Or is there any other way to achieve the same
Use the APIs these companies usually offer.

Resources