Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It is not taking into account Options #5

Closed
godofredoninja opened this issue Jan 23, 2019 · 5 comments
Closed

It is not taking into account Options #5

godofredoninja opened this issue Jan 23, 2019 · 5 comments

Comments

@godofredoninja
Copy link

Hi πŸ˜„

I realize there's a little problem
When you add options for the Api it is not taking into account.

β€” For example

api: {
	resource: 'posts',
	parameters: { 
		limit: 10,
		fields: ['title', 'slug', 'custom_excerpt'],
	},
},

As you can see, I only call 10 post, but It return all post and does not take into account any of these options that is added.

β€” Checking the code, I think I found the possible error.

browse.limit = 'all';

This is solved by removing this line.
It is also necessary to update the documentation with the new values that the version two of the Api accepts.

@NistorCristian
Copy link
Contributor

Hi,

limit = 'all' is mandatory because there is no other way to do this in Ghost, at this moment. If you set limit to 10 you will search only in the latest 10 posts. So if you have 100 posts and search for 'car', you will search in the latest 10 posts. Maybe you have 'car' as a word in posts 23, 44, etc too. Those will not return if you change the value to 10.

The 'fields' value should work. I tested and it does.

If you want to limit the number of posts that you want to show see Option's limit.

Thanks for pointing out that I have to update the docs for v2. Will do these days.

Let me know if this is clear enough.

@godofredoninja
Copy link
Author

Hi πŸ˜„

The limit of 10 only I gave you as an example.

Having limit = 'all' on small web pages is perfect.

But if the page has about 5 thousand post this is no longer good. because you have to download a large amount of data and this becomes a very heavy json.

That is why the post limit so that it can work well with a certain amount of data.

Have a good day πŸ˜„

@NistorCristian
Copy link
Contributor

Yeah, if you have 5000 posts the search will most likely break. So limit should be editable I guess. Another way to 'limit' could be to filter the posts that were published in the last 1-2 years. Depends on how regulary you post. I will make it editable in the next release.

@NistorCristian
Copy link
Contributor

Now, in version 1.0.1 you can change the api parameters limit too. Keep in mind that if you change this value you might not get the same results as you should. If you have a small blog you can leave it to all. Up to 200 posts should work without a problem especially because, by default, we only get the title and the slug.

If you have a lot of posts you could change this value and set it to a number that makes sense. You could look at how many posts you published in the latest 2-3 years and perform the search only on those posts. Not ideal but better than a slow, very slow, search. Or you could use filter parameter and set the published_at greater than a specific date.

@godofredoninja
Copy link
Author

Thank you. You did a good job.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants