improve search for hints by title
authorJan Szejko <janek37@gmail.com>
Mon, 23 Oct 2017 12:31:19 +0000 (14:31 +0200)
committerJan Szejko <janek37@gmail.com>
Mon, 23 Oct 2017 12:31:19 +0000 (14:31 +0200)
doc/schema.xml
src/search/index.py

index a202781..33886be 100644 (file)
    <field name="authors" type="text_general" stored="false" indexed="true" multiValued="true" termPositions="true" termVectors="true"/>
    <field name="translators" type="text_general" stored="false" indexed="true" multiValued="true" termPositions="true" termVectors="true" />
    <field name="title" type="text_pl" stored="false" indexed="true"/>
-   <field name="title_orig" type="text_general" stored="false" indexed="true"/>
+   <field name="title_orig" type="lowercase" stored="true" indexed="true"/>
 <!--   <field name="published_date" type="tdate" stored="false" indexed="true"/>-->
    <field name="published_date" type="string" stored="true" indexed="true"/>
 
 
   <copyField source="themes" dest="themes_pl"/>
   <copyField source="tag_name" dest="tag_name_pl"/>
+  <copyField source="title" dest="title_orig"/>
 
 <!--
    <copyField source="cat" dest="text"/>
index ff7d7f8..1cac82e 100644 (file)
@@ -913,8 +913,10 @@ class Search(SolrIndex):
         query = query.strip()
         if prefix:
             q |= self.index.Q(title=query + "*")
+            q |= self.index.Q(title_orig=query + "*")
         else:
             q |= self.make_term_query(query, field='title')
+            q |= self.make_term_query(query, field='title_orig')
         qu = self.index.query(q)
         only_books = self.index.Q(is_book=True)
         return self.search_books(qu, [only_books])