Upgrading elasticsearch to 1.7.0, pyes to 0.99.5, and modern querying for stories. Needs a reindex. Still need to do feeds.

This commit is contained in:
Samuel Clay 2015-07-17 14:01:38 -07:00
parent fe52578879
commit b51a054c1c
3 changed files with 17 additions and 7 deletions

View file

@ -1,16 +1,26 @@
import re
from django.core.management.base import BaseCommand
from django.contrib.auth.models import User
from apps.rss_feeds.models import Feed
from apps.rss_feeds.models import Feed, MStory
from apps.reader.models import UserSubscription
from optparse import make_option
class Command(BaseCommand):
option_list = BaseCommand.option_list + (
make_option("-u", "--user", dest="user", nargs=1, help="Specify user id or username"),
make_option("-R", "--reindex", dest="reindex", action="store_true", help="Drop index and reindex all stories."),
)
def handle(self, *args, **options):
if options['reindex']:
MStory.index_all_for_search()
return
if not options['user']:
print "Missing user. Did you want to reindex everything? Use -R."
return
if re.match(r"([0-9]+)", options['user']):
user = User.objects.get(pk=int(options['user']))
else:

View file

@ -202,28 +202,28 @@ class SearchStory:
'index': 'analyzed',
'store': 'no',
'type': 'string',
'analyzer': 'snowball',
'analyzer': 'standard',
},
'content': {
'boost': 1.0,
'index': 'analyzed',
'store': 'no',
'type': 'string',
'analyzer': 'snowball',
'analyzer': 'simple',
},
'tags': {
'boost': 2.0,
'index': 'analyzed',
'store': 'no',
'type': 'string',
'analyzer': 'snowball',
'analyzer': 'standard',
},
'author': {
'boost': 1.0,
'index': 'analyzed',
'store': 'no',
'type': 'string',
'analyzer': 'keyword',
'analyzer': 'simple',
},
'feed_id': {
'store': 'no',
@ -272,7 +272,7 @@ class SearchStory:
cls.ES.indices.refresh()
sort = "date:desc" if order == "newest" else "date:asc"
string_q = pyes.query.StringQuery(query, default_operator="AND")
string_q = pyes.query.QueryStringQuery(query, default_operator="AND")
feed_q = pyes.query.TermsQuery('feed_id', feed_ids[:1000])
q = pyes.query.BoolQuery(must=[string_q, feed_q])
try:

View file

@ -27,7 +27,7 @@ mongoengine==0.8.2
nltk==2.0.5
oauth2==1.5.211
psutil==2.1.0
pyes==0.90.1
pyes==0.99.5
simplejson==3.4.0
pyflakes==0.6.1
pymongo==2.6