Django search with Whoosh but no Haystack? - django

I'm just wondering what is exactly the functionality that haystack provides and if I need it.
I mean the search and indexing is done by whoosh. As far as I can tell, haystack is just offering ready made views, and forms. If I want to write my own form and views do I still need haystack?
Am I missing something?
P.S. I don't plan to use any other search engine than whoosh so I also don't need haystacks's multiple search engine wrapping.

Besides views, forms and a search engine-agnostic layer, the other powerful thing about Haystack is its ability to map Django models to something the search index understands. Using Haystack, you can easily specify which fields in a model should be indexed and how (see the SearchIndex API - http://django-haystack.readthedocs.org/en/latest/searchindex_api.html).
Once you have done that, you can then leverage the built-in management commands to (re)index your data when required.
It also comes with some nice templatetags to help present search results, like highlighting the matching bits.
Is there a particular reason that you don't want to use Haystack? It is a pretty non-intrusive plugin that lets you use as much of it as you need, and makes it easy to use more advanced functionality when you need it later down the road. In one of the sites I built, I only used the SearchIndex and SearchQuerySet APIs; I built my own views and forms. Ultimately, if you end up writing your own indexing and searching code, views and forms, you have basically re-written a large part of Haystack, in which case, you may want to consider using something that is in use out there and reasonably well tested.
That said, I have rolled my own 'Haystack' like layer in another project, mainly because the data source didn't map to the Django ORM. In that case, I wrote my own indexing scripts, and used PySolr to interface with my Apache Solr instance.
Given that Whoosh is written in Python, I'd assume it has a decent Python interface, so it shouldn't be too hard to do. I would only do it if there's something special about your scenario though.

Related

How to add "similar results" section on mysite using django?

I want to add the functionality that can pop up the similar results with every search query the user input.
I would be using it locally, so no google haystack search or something.
Not sure I follow: to get anything meaningful, especially as someone new to the language, you're going to need to use an external search package. If you're uncomfortable setting up something like Elasticsearch locally, you can start with Whoosh which can be installed with pip. I would highly recommend using Haystack as it abstracts away what you use under the covers to make it friendlier to work with and allows you to swap out for something stronger than Whoosh in the future. Here's a list of back-ends: they all support the “More Like This” functionality. If you're insistent on not using Haystack, here's a previous answer about how to get started in Whoosh.

Django Haystack a good fit for this type of search?

I have an application that lists jobs within a certain location using spatial search. It is a fairly simple search with a few filters (date range, job type, etc) no large text to search. I was considering using something like Haystack with solr to do the search, is it worth the overhead or should I just query the database?
This sort of thing can be easily handled via Solr (or any of Haystack's other backends), but if you start with your database (see Django Filter for ideas to make this easy via URLs), and then shift to a search engine when the need arises (based on load), you'll thank yourself later for not introducing more complexity early on.
When you do add the search engine, whichever you use, definitely use Haystack as the API, unless you go with Sphnix, in which case maybe see this blog post.

Django and Neo4j without Neo4Django

I'm build a Django app with Neo4j (along with Postgres), I found this Django integration called neo4django, I was wondering if it's possible to use neo4restclient only, like, what would be the disadvantages of not using Neo4django? Does using neo4-rest-client only, give me more flexibility?
When I was creating my models with Neo4Django, it seemed that there is no difference between modeling a graph db and relational db. Am I missing anything?
Thanks!
You can absolutely go ahead with neo4j-rest-client or py2neo, without using neo4django. In the same way, you can use any other database driver you'd like any time using Django, any REST client, etc.
What'll you lose? The model DSL, the built-in querying (eg, Person.objects.filter(name="Mohamed")), the built-in indexing, and the Lucene, Gremlin and Cypher behind that. Some things will be much easier- like setting an arbitrary property on a node- but you'll need to learn more about how Neo4j works.
You'll also lose some of the shortcuts Django provides that work with neo4django, like get_object_or_404() and some of the class-based views that work with querysets.
What'll you gain? Absolute power over the DB, and an easier time tweaking DB performance. Though neo4django isn't nearly as good a lib as some traditional ORMs in the Python sphere, the trade-off of power vs provided ease is similar.
That said, the two can work together- you can drop down from neo4django to the underlying REST client nodes and relationships anytime. Just use model_instance.node to get the underlying neo4j-rest-client node object from a model, and from neo4django.db import connection to get a wrapped neo4j-rest-client GraphDatabase.
On whether you're missing something: neo4django was written to re-use a powerful developer interface- the Django ORM- so it should feel similar to writing models for Postgres. I've written a bit about that odd feeling in the past. I think part of the problem might be that the lib doesn't highlight the graph terminology new graph-interested devs expect- like traversals and pattern matching- and instead dresses those techniques in Django query clothing.
I'd love your thoughts, or to know anything you'd like the library to do that it isn't doing :) Good luck!

Django simple-pages stable or not?

I want to create a pretty simple site with a few pages using Django. I guess I could use Wordpress. But there is some custom stuff (like a special kind of calendar app) that I rather do in Python than PHP.
I came across simple-pages which seems like a nice middle way between flat-pages and a fullblown Django CMS (which just seems overkill). It can automatically generate menus. But it seems like it hasn't been updated in a long time. Is it deprecated or is it stable? Or do flat-pages have the same functionality these days?
Honestly, It would be super easy to build your own small custom CMS since you know python. It would only take a few models and not a lot of time - the result being something better customized for your needs.
I've used some of these examples before - and they work ok, but I always find myself having to add something more.
One idea is to check out what sub-applications some of these things are using - maybe import only what you really need.
But I almost always find myself spending a LITTLE extra time to build out my own schema/structure for simple pages Then using a nice admin skin like grappelli when handing it over to clients (you get SORT of that wordpress feel (sort of))
Lots of admin customization that can make it easy for clients (and You) to work with static pages.

django-nonrel on Google App Engine - Implications of using ListField for ManyToMany

I am working on a Google App Engine application and I am relatively new at this.
I have built an app already in Django and have a model using a field type of ManyToMany.
I am aware that django-nonrel does not support many-to-many field types of Django. So I am considering using ListField instead.
Questions:
- What is the implication of using ListField instead of ManyToMany?
- I am aware that this means that Django's JOIN API cannot be used. But what does this mean for my app?
- Am I going to have problems when it comes to doing a search for something in a many-to-many field?
Apologies if these are programming 101 questions. I'm a designer trying to get my head around development.
Thanks
Well as you probably know, you will be spanning the relationship more manually.
Django cannot help quite as much as when using ManyToMany, but it should not be that big a problem.
Depending on the complexity of the relationship, you might want to consider building a model just for this purpose.
I have never used that approach on GAE, since IMO its only valid when an object has alot relations (more than 50 I would say) or when the lookups you plan to do, will benefit from this. Maybe because they start at either end of the relationship with equal frequency or it would be nice to be able to loop over the relationships to display them or something along those lines.
Last time I made something on GAE I used the ListField (or ListProperty as it was known then) since most of the objects only had about 20 related objects and the lookups would rarely go the other way.
So all in all, its not a big deal and I don't remember it as any kind of a pain to work with/around.
Hope this was helpful despite it being rather "IMO"