Is there a way to find related articles of a given article in sphinx? I will be using the title and the articles content for the query. I need something like lucenes More like this feature. How can I do this in Sphinx?
You could use quorum from your 'title' words to get similar documents, ie "greatest cars in england"/2 gives you list of related documents. You could narrow you search by excluding common words, articles by building stopwords list and issue "call keywords" request to daemon.
Related
I want to send search requests to Spotify's Web API. They have a search endpoint described in their docs. The URL query requires two parameters:
type of the searched item (i.e. album or track)
q which is the actual search query
The format of q is not clear to me. I can just enter search terms. For example if I want to find the song 'As It Was' from 'Harry Styles' I can just enter As It Was Harry Styles and the first returned item is the correct song. So far so good. But the description for q states that:
You can narrow down your search using field filters. The available filters are album, artist, track, year, upc, tag:hipster, tag:new, isrc, and genre. Each field filter only applies to certain result types.
They even provide an example:
remaster%20track:Doxy%20artist:Miles%20Davis
Using filters seems much more secure and better to me than just enter any terms into q. Especially, because for the items I search for, I will always have the title and the artist. But the problem is, I always receive empty responses. Even with the provided example query (and yes, that song exists, I looked it up (you can use literally the example query in the search interface of your Spotify app)).
So how do I use these filters?
What is this remaster in the begin? Just another search term?
Has anybody some experience with this and can help?
Unfortunately, I could not find anything on the web describing the query in more detail.
Suppose I have a simple blog with the data type of Article and the data type of ArticleTag:
Article ->
title - Title field
tag - Content relationship to ArticleTag
ArticleTag ->
title - Title field
icon - Text field
For that purpose, I would like to return query all ArticleTags and get each with N Articles (or even all of them), but the API documentation (both GraphQL and REST) is awfully silent on how to expand reverse content relationships. i.e. they only specify how to get fields from ArticleTag per Article (or how to get all Articles with a specific ArticleTag per id which is strange but whatever)
I can think of a workaround: query all tags, then for each tag query all articles. Thing is that this sounds awfully slow as it generates N+1 API requests for the number of tags I have, plus, this may be happening on the client-side as well in this project! So I'd rather avoid that if in any way possible.
Yeah the workaround you presented is the only way to do that.
My api should support text search on specified fields. So I am thinking what kind of URL style handles it in the best way.
The below pattern, using "q" ,is mentioned in many blogs and documents to be used for full text search but I also need to specify field names:
GET /groups?q=bank+org
So I am thinking to use wildcards like below:
GET /groups?name=*bank*&owner=*org*
I am just wondering if this is aligned with the best practices in the market?
Thanks
Soheil, you are thinking right. "Search" is a "filter parameter" wich always go in the Query String.
When sending parameters that will be used to query a collection of resources you should use... Guess what! Query parameters!
As far as I know, there's no official documentation that states that. It's a common approach and it's widely adopted. The only offical documentation about query string that I'm aware of is the RFC 3986. Quoting:
3.4. Query
The query component contains non-hierarchical data that, along with
data in the path component, serves to identify a
resource within the scope of the URI's scheme and naming authority
(if any). The query component is indicated by the first question
mark ("?") character and terminated by a number sign ("#") character
or by the end of the URI. [...]
For a full text search, you can choose the parameter you find most convenient. Do you think q is a good one? Go for it! But provide a good documentation for it.
The database is MongoDB, not SQL, and that isn't going to change.
Suppose you have an app that allows users to post questions and then tag them with a single subject: math, science, english, history.
Also, on the nav, each subject has its own tab that will display questions that are tagged with the corresponding subject.
Since the display of questions by tag is essential to the app, what is the fastest way to retrieve this data?
Possibilities:
(1) Leave the tags as a single field in the questions collection. Problem: Would have to search through every question, then search through the tags field, to find the relevant tags.
(2) A tag collection, with a field for each subject. Problem: if the number of questions grow too large (approx 20,000 posts), Mongo won't work. From the Mongo docs (http://blog.mongodb.org/post/35133050249/mongodb-for-the-php-mind-part-3):
With document design you need to consider two things: scale and
search. ScaleMongoDB Documents have a limit of 16MB, which although
sounds quite small, can accommodate thousands of documents. However if
you are expecting 20,000 comments per post on a high traffic website,
or your comments are unlimited in size, then embedding might not work
well for you.
This seems to leave...
(3) A separate collection for each tag. Is (3) best in this case?
From the (rather rudimentary) spec you give, I'd go for a single collection for the documents, where each document contains an array of tags:
{
_id: "whatever",
content: "the question",
tags: [ "this", "that", "and another tag" ]
...
}
Then, for efficient querying by tag, set a multi-key index on the tags.
See https://docs.mongodb.com/manual/indexes/#multikey-index
I'm trying to figure out the best approach for tagging posts in my express application. There are two types of post, say 'Phones' and 'Tablets'. They both can share tags but require different Models to access them (this wont change).
I opened up Wordpress to see how it handles tags, but there is a lot of replica data in the DB and I don't feel this is right for my application.
Should I store tags as a String with a delimiter and query it within the post? Or should I create a new table for those tags that has a post ID associated with the list of tags so that when I search I only have to search that given table, rather than two different ones?
Thanks
As long as document will not exceed 16MB I will keep tags inside a document as an array field.
Then I will create an index on tags field - to have an easy way to display documents containing specific tag (mongo will index all array entries and provide fast search).