How to search the post by several keywords and category and author's name by assets resource endpoint

8 views
Skip to first unread message

Pony

unread,
Apr 27, 2011, 5:48:29 AM4/27/11
to TypePad Developers Network
I found the full-text search api to get the posts ( /assets.<format>).
But the Full-text Queries only support the content and the title, and
the amount of the keyword should be only one. How can I deal with the
situation of more than one keywords? If the queries are category and
the author's display-name, the endpoint can't deal with this
situation. I found that we can set the author's id in the filter. But
how can I get the author's id by the author's display-name? Is there
any solution to deal will the the queries of several keywords category
and author's display-name.

Martin Atkins

unread,
Apr 27, 2011, 10:17:55 AM4/27/11
to typepad-d...@googlegroups.com

You can actually have as many keywords as you like, separated by spaces.

For example, you can search for:
"foo" title:"baz"

and the API will return assets that have "foo" anywhere AND have "baz"
in their title.

As you saw, the author's display name is not included in the search
index. If you know the user's profile username (the username that goes
after http://profile.typepad.com/ in the user's profile URL) then you
can use it as the id of the /users/{id} endpoint to obtain the user id
you need for the filter.user parameter, which will be in the "urlId"
property.

The category names *are* included in the search index, but there is no
special "category:" prefix that allows you to search just that field. A
post that is categorized as "foo" is eligible to be included in a query
for just "foo", but obviously not title:"foo" or content:"foo".

If you are looking for posts in a specific blog, the more specific
endpoint /blogs/<id>/post-assets/@by-category/<id> allows you to get the
posts in the blog that have the given category, and will do so more
reliably than a query to /assets with a filter.blog parameter, since the
latter is subject to search index delay, index ranking/blocking, etc.

I hope this information brings you closer to what you're trying to do.
If you can share more information about your goals we might be able to
come up with another way to approach the problem.

Thanks,
Martin

Pony

unread,
Apr 28, 2011, 6:33:50 AM4/28/11
to TypePad Developers Network
Hello Martin, thank you for the response. It is helpful very much.
I have a doubt on the the queries. I can have many keywords, separated
by spaces.
But the logic between them is AND. It means I will get the posts that
contain all of the keywords.
If I want the results that contain part of the keywords, what can I
do?
For example, we have three keywords. keyword1, keyword2, keyword3.
I want the post that contain one or more of them. The logic between
the keywords is OR.
How can I achieve this?

Best regards,

Pony


On Apr 27, 10:17 pm, Martin Atkins <matk...@saymedia.com> wrote:
> On 04/27/2011 02:48 AM, Pony wrote:
>
> > I found the full-text search api to get the posts ( /assets.<format>).
> > But the Full-text Queries only support the content and the title, and
> > the amount of the keyword should be only one. How can I deal with the
> > situation of more than one keywords? If the queries are category and
> > the author's display-name, the endpoint can't deal with this
> > situation. I found that we can set the author's id in the filter. But
> > how can I get the author's id by the author's display-name? Is there
> > any solution to deal will the the queries of several keywords category
> > and author's display-name.
>
> You can actually have as many keywords as you like, separated by spaces.
>
> For example, you can search for:
>      "foo" title:"baz"
>
> and the API will return assets that have "foo" anywhere AND have "baz"
> in their title.
>
> As you saw, the author's display name is not included in the search
> index. If you know the user's profile username (the username that goes
> afterhttp://profile.typepad.com/in the user's profile URL) then you

Martin Atkins

unread,
Apr 28, 2011, 12:26:33 PM4/28/11
to typepad-d...@googlegroups.com
On 04/28/2011 03:33 AM, Pony wrote:
> Hello Martin, thank you for the response. It is helpful very much.
> I have a doubt on the the queries. I can have many keywords, separated
> by spaces.
> But the logic between them is AND. It means I will get the posts that
> contain all of the keywords.
> If I want the results that contain part of the keywords, what can I
> do?
> For example, we have three keywords. keyword1, keyword2, keyword3.
> I want the post that contain one or more of them. The logic between
> the keywords is OR.
> How can I achieve this?
>

Unfortunately our search system does not currently support OR, it only
supports AND and NOT. In designing our search query syntax we optimized
for the common cases, and decided not to provided complex boolean
expressions.

You might enjoy some success performing one query for each of your OR
clauses, but of course you will then need to figure out how to merge the
results since there will not be a common ranking order across the
multiple queries.

I'm sorry we don't have an easier solution for this. The search API is
primarily designed to power a straightforward search UI on a blog, so it
doesn't support more the advanced querying capabilities that you seem to
need.


Reply all
Reply to author
Forward
0 new messages