As described at playframework - search module, I've installed the search-module. Of course my model consists of multiple classes. I'd now like to search for entries whose attributes consist of several tables, i.e. i'd like to search for users who have bought an article that costs more than say 500$ whereas there would be a table for customers, one for orders and one for articles.
Does anyone know how to realize this using the playframework's lucene-query-language?
thanks a lot!
The query language isn't specific to Play! You can learn about the syntax from the official Lucene documentation: http://lucene.apache.org/java/2_0_0/queryparsersyntax.html
Related
I am aware of database relations, I was taught similar like this below:
I am developing an web apps with strapi cms, in there I can see some relations those are not named academic like one to one, one to many etc. vice-versa. Instead they used has one, belongs to many something like this. Not only strappy, I have also encountered this in some other ORM documentations as well. Which is completely okay, but I am not understanding to relate with the above image.
In stripy also the relational symbols are different than the above image.
For example:
Has One:
Has and belongs to one
Belongs to many
Has Many
Has and belongs to many
Has many
I need to know these phrases to relate, is one to many similar to has many?, is one to one similar to has one? etc. Also, what is the benefit of use these phrases rather than one to one etc.? Is it a topic in DB systems I may be missed?
There are lots of different notations for describing relationships, each with its own vocabulary. There’s a reasonable description of them here.
On top of these, individual products may use their own, non-standard, notations
I have an app built on Flask, using sqlalchemy as an ORM, it will have books with an upvote system based on multiple languages as columns, so if a book has been translated to 20 languages, each language will have its own voting score.
Some books could have 30 languages available and some only one.
Is it possible to have multiple columns being optional?
Any pointers to how I should tackle this?
I am fairly new to sql. So I'm not sure how to do proper research on this. I was following Miguel Grinberg's Micro blog tutorial and while his followers system is somewhat similar, I'm not sure how to extend it to my case. Any help is appreciated.
There's many possible ways to do this.
I would probably do something like:
Have model/table books.
Have model/table languages.
Have model/table book_in_language, which has some rating (which is probably aggregated from user_book_in_language_rating table.
I am trying to design a database with search-ability at its core. My knowledge of database design and SQL is all self-taught and still fairly beginner-level, so my questions may possibly have easy answers.
Suppose I have a single table containing a large number of records. For example, suppose that each record contains details of a different computer application (name, developer, version number, etc). A list of keywords are associated with each record, such as a list of programming languages used to write the applications.
I wish to be able to enter one or more keywords (each separated by a space) into a search box, and I wish to have all associated records returned. How should I design the database to store the keywords, and what SQL query would I need to apply to the search text? (The search should be uppercase/lowercase independent.)
My next challenge would then be to order search results by relevance, and to allow entire key-phrases as well as keywords to be associated with each record. For example, if I type "Visual Basic" into the search field, I want the first results to have exactly the key-phrase "Visual Basic" associated with them. The next results should all have both keywords "Visual" and "Basic" associated with them, and the remaining results should have only one of these keywords. Again, please could anyone advise on how to implement this?
The final challenge I believe would be much harder: how much 'intelligent interpretation' can I design my database and SQL code to handle? For example, if I search for "CSS", can I get the records with the key-phrase "Cascading Style Sheets" to appear? Can I also get SQL to identify and search for similar words, such as plurals of search phrases or, for example, "programmer" or "programming" when "program" is input? Thanks!
Learn relational algebra, normalization rules, and SQL.
Start with entity relationships. Sounds like you could have an APPLICATION table as parent for a FEATURE child table, with a one-to-many relationship between the two. You'll query them by JOINing one to the other:
SELECT A.NAME, F.NAME
FROM APPLICATION AS A
JOIN FEATURE AS F
ON F.APP_ID = A.ID
Your challenges would not suggest SQL and relations to me. I would think more in terms of a parser, an indexer and search engine like Lucene, and a NoSQL document database like MongoDB.
I've come to the conclusion, after a LOT of research, that #duffymo's answer is hinting in the right direction. For the benefit of other n00bs like me, here's the conclusion I've drawn:
Many open source search engine server apps are out there to install for free. Lucene was the first I had ever heard of them, but others do exist and I think my favourite at the moment is Sphinx. As far as I can tell, the 'indexer' that #duffymo mentions is built into it. I have learnt that the indexer is the program that will examine my database for keywords and will automatically keep a record of which results should be returned for different input queries. I have also now learnt that the terminology for the behaviour I was looking for (and which Sphinx has) is 'stemming'. I'm still not sure what role a parser plays in all this...
A more basic approach would be to use SQL itself. Whilst I was already aware of the most basic of these (ie. using the LIKE keyword with 'wildcards'), I also discovered something a little more powerful: natural language / full-text search. For anyone not interested in installing a server app, I recommend you look this up.
Also, I see no reason why I would need to use NoSQL instead of SQL (as #duffymo has suggested), and so I'm going to stick with SQL for the moment (at least until I come across some good entry-level books to learn NoSQL from). Furthermore, I have very little intention to learn relational algebra until I know why I should and how it would be useful. The message here is that other beginners shouldn't be off-put by these things, as I don't think Sphinx requires any knowledge of them.
while I like #duffymo's answer, I will also suggest you research SPARQL and the wordnet project for your semantic equivalence questions.
If you choose Oracle, you can use the spatial option triple store to implement the SPARQL endpoint and do some very nice seaching like your css = Cascading Style Sheet example.
So I have a Many to Many relationship between Record and Counties in Rails, such that when I am creating a record, the user can select multiple counties. The problem is that there are over 100 counties to choose from.
So I'm looking for a more user friendly way to allow selection of multiple counties than what comes with formtastic's default.
I found this blog, but the plugin it references is a bit old and doesn't seem available anymore....http://diminishing.org/extending-formtastic-with-a-sprinkle-of-jquery
Anyone implement anything with Rails 3/Formtastic to tackle this problem?
Thanks in advance.
I have just used Select2 in a project with Rails 3 and Formtastic and it works quite well.
Select2 supports multi-value select boxes, so if the select is declared with the multiple attribute then Select2 will automatially pick up on that. Thus, all you need is to do the following:
$("#multiple_select").select2();
More documentation here: http://ivaynberg.github.io/select2/
I’ve found multiple questions on SO and elsewhere that ask questions along the lines of “How can I index and then search relational data in Lucene”. Quite rightly these questions are met with the standard response that Lucene is not designed to model data like this. This quote I found sums it up…
A Lucene Index is a Document Store. In a Document Store, a single
document represents a single concept with all necessary data stored to
represent that concept (compared to that same concept being spread
across multiple tables in an RDBMS requiring several joins to
re-create).
So I will not ask that question and instead provide my high level requirements and see if any Lucene gurus out there can help me.
We have data on People (Name, Gender, DOB, Nationality, etc)
And data on Companies (Name, Country, City, etc).
We also have data about how these two types of entity relate to each other where a person worked at the company (Person, Company, Role, Date Started, Date Ended, etc).
We have two entities – Person and Company – that have their own properties and then properties exist for the many-to-many link between them.
Some example searches could be as follows…
Find all Companies in Australia
Find all People born between two dates
Find all People who have worked as a .Net Developer
Find all males who have worked as a.Net Developer in London.
Find all People who have worked as a .Net Developer between 2008 and 2010
The criteria span all the three sets of data. Our requirement is to provide a Faceted Search over the data that accepts any combination of the various properties, of which I have given some examples.
I would like to use Lucene.Net for this. We are a .Net software house and so feel slightly intimidated by java. However, all suggestions are welcome.
I am aware of the idea that the Index should be constructed with the search in mind. But I can’t seem to come up with a sensible index that would meet all the combinations of search criteria
What classes native to Lucene or what extension points can we make use of.
Are there are established techniques for doing this kind of thing?
Are there any third open source contributions that I have missed that will help us here?
For now I won’t describe the scenarios we have considered because I don’t want to bloat out this question and make it too intimidating. Please ask me to elaborate where necessary.
To store both companies and people in a single index, you could create documents with a type field that identifies the type of entities they describe.
Birthdays can be stored as date fields.
You could give each person a simple text field containing the names of companies that they worked for. Note that you won't get an error if you enter a company that is not represented by a document in your index. Lucene is not a relational DB tool, but you knew that.
(Sorry that I've not posted any links to the API; I'm familiar with Lucene Core but not Lucene.NET.)