Browse Source

search from english, fix #467

Bachir Soussi Chiadmi 4 years ago
parent
commit
7246675e32

+ 141 - 109
config/sync/search_api.index.collection.yml

@@ -5,31 +5,24 @@ dependencies:
   config:
     - field.storage.node.body
     - field.storage.node.field_description
-    - field.storage.node.field_transcript_trad
-    - field.storage.node.field_transcript_vo
     - field.storage.node.field_entrees
-    - field.storage.node.field_locuteurs
-    - field.storage.node.field_workflow
     - field.storage.node.field_genres
-    - field.storage.node.field_langues
     - field.storage.taxonomy_term.field_synonyms
+    - field.storage.node.field_langues
+    - field.storage.node.field_locuteurs
+    - field.storage.node.field_transcript_trad
+    - field.storage.node.field_transcript_vo
+    - field.storage.node.field_workflow
     - search_api.server.edlp_db
   module:
     - taxonomy
-    - search_api
     - node
+    - search_api
 id: collection
 name: Collection
 description: ''
 read_only: false
 field_settings:
-  node_grants:
-    label: 'Node access information'
-    property_path: search_api_node_grants
-    type: string
-    indexed_locked: true
-    type_locked: true
-    hidden: true
   body:
     label: Article
     datasource_id: 'entity:node'
@@ -38,12 +31,6 @@ field_settings:
     dependencies:
       config:
         - field.storage.node.body
-  title:
-    label: Title
-    datasource_id: 'entity:node'
-    property_path: title
-    type: text
-    boost: !!float 3
   field_description:
     label: Description
     datasource_id: 'entity:node'
@@ -53,64 +40,73 @@ field_settings:
     dependencies:
       config:
         - field.storage.node.field_description
-  field_transcript_trad:
-    label: 'Transcription (Traduction)'
+  field_entrees:
+    label: Entrée(s)
     datasource_id: 'entity:node'
-    property_path: field_transcript_trad
-    type: text
-    boost: 0.8
+    property_path: field_entrees
+    type: integer
     dependencies:
       config:
-        - field.storage.node.field_transcript_trad
-  field_transcript_vo:
-    label: 'Transcription (Version Originale)'
+        - field.storage.node.field_entrees
+  field_genres:
+    label: 'Genre(s) » Taxonomy term » Name'
     datasource_id: 'entity:node'
-    property_path: field_transcript_vo
+    property_path: 'field_genres:entity:name'
     type: text
-    boost: !!float 8
     dependencies:
       config:
-        - field.storage.node.field_transcript_vo
-  status:
-    label: status
+        - field.storage.node.field_genres
+      module:
+        - taxonomy
+        - taxonomy
+  field_langues:
+    label: 'Langue(s) » Taxonomy term » Name'
     datasource_id: 'entity:node'
-    property_path: status
-    type: boolean
-    indexed_locked: true
-    type_locked: true
-  uid:
-    label: uid
+    property_path: 'field_langues:entity:name'
+    type: text
+    dependencies:
+      config:
+        - field.storage.node.field_langues
+      module:
+        - taxonomy
+        - taxonomy
+  field_locuteurs:
+    label: Locuteur(s)
     datasource_id: 'entity:node'
-    property_path: uid
+    property_path: field_locuteurs
     type: integer
-    indexed_locked: true
-    type_locked: true
-  name:
-    label: 'Entrée(s) » Taxonomy term » Name'
+    dependencies:
+      config:
+        - field.storage.node.field_locuteurs
+  field_synonyms:
+    label: 'Genre(s) » Taxonomy term » Synonyms'
     datasource_id: 'entity:node'
-    property_path: 'field_entrees:entity:name'
+    property_path: 'field_genres:entity:field_synonyms'
     type: text
     dependencies:
       config:
-        - field.storage.node.field_entrees
+        - field.storage.node.field_genres
+        - field.storage.taxonomy_term.field_synonyms
       module:
         - taxonomy
-  field_entrees:
-    label: Entrée(s)
+  field_transcript_trad:
+    label: 'Transcription (Traduction)'
     datasource_id: 'entity:node'
-    property_path: field_entrees
-    type: integer
+    property_path: field_transcript_trad
+    type: text
+    boost: 0.8
     dependencies:
       config:
-        - field.storage.node.field_entrees
-  field_locuteurs:
-    label: Locuteur(s)
+        - field.storage.node.field_transcript_trad
+  field_transcript_vo:
+    label: 'Transcription (Version Originale)'
     datasource_id: 'entity:node'
-    property_path: field_locuteurs
-    type: integer
+    property_path: field_transcript_vo
+    type: text
+    boost: !!float 8
     dependencies:
       config:
-        - field.storage.node.field_locuteurs
+        - field.storage.node.field_transcript_vo
   field_workflow:
     label: Workflow
     datasource_id: 'entity:node'
@@ -119,37 +115,65 @@ field_settings:
     dependencies:
       config:
         - field.storage.node.field_workflow
-  field_genres:
-    label: 'Genre(s) » Taxonomy term » Name'
+  langcode:
+    label: Langue
     datasource_id: 'entity:node'
-    property_path: 'field_genres:entity:name'
-    type: text
+    property_path: langcode
+    type: string
     dependencies:
-      config:
-        - field.storage.node.field_genres
       module:
-        - taxonomy
-  field_langues:
-    label: 'Langue(s) » Taxonomy term » Name'
+        - node
+  language_with_fallback:
+    label: 'Language (with fallback)'
+    property_path: language_with_fallback
+    type: string
+  name:
+    label: 'Entrée(s) » Taxonomy term » Name'
     datasource_id: 'entity:node'
-    property_path: 'field_langues:entity:name'
+    property_path: 'field_entrees:entity:name'
     type: text
     dependencies:
       config:
-        - field.storage.node.field_langues
+        - field.storage.node.field_entrees
       module:
         - taxonomy
-  field_synonyms:
-    label: 'Genre(s) » Taxonomy term » Synonyms'
+        - taxonomy
+  node_grants:
+    label: 'Node access information'
+    property_path: search_api_node_grants
+    type: string
+    indexed_locked: true
+    type_locked: true
+    hidden: true
+  status:
+    label: status
     datasource_id: 'entity:node'
-    property_path: 'field_genres:entity:field_synonyms'
+    property_path: status
+    type: boolean
+    indexed_locked: true
+    type_locked: true
+    dependencies:
+      module:
+        - node
+  title:
+    label: Title
+    datasource_id: 'entity:node'
+    property_path: title
     type: text
+    boost: !!float 3
     dependencies:
-      config:
-        - field.storage.node.field_genres
-        - field.storage.taxonomy_term.field_synonyms
       module:
-        - taxonomy
+        - node
+  uid:
+    label: uid
+    datasource_id: 'entity:node'
+    property_path: uid
+    type: integer
+    indexed_locked: true
+    type_locked: true
+    dependencies:
+      module:
+        - node
 datasource_settings:
   'entity:node':
     bundles:
@@ -157,31 +181,17 @@ datasource_settings:
       selected:
         - enregistrement
     languages:
-      default: true
-      selected: {  }
+      default: false
+      selected:
+        - en
+        - fr
 processor_settings:
-  entity_status: {  }
-  rendered_item: {  }
-  tokenizer:
-    all_fields: true
-    fields:
-      - body
-      - title
-      - field_description
-      - field_transcript_trad
-      - field_transcript_vo
-      - name
-      - field_genres
-      - field_langues
-      - field_synonyms
-    spaces: ''
-    overlap_cjk: 1
-    minimum_word_size: '3'
-    weights:
-      preprocess_index: -6
-      preprocess_query: -6
-  aggregated_field: {  }
   add_url: {  }
+  aggregated_field: {  }
+  content_access:
+    weights:
+      preprocess_query: -30
+  entity_status: {  }
   html_filter:
     all_fields: false
     fields:
@@ -192,11 +202,11 @@ processor_settings:
     title: true
     alt: true
     tags:
+      b: 2
       h1: 5
       h2: 3
       h3: 2
       strong: 2
-      b: 2
     weights:
       preprocess_index: -15
       preprocess_query: -15
@@ -204,40 +214,62 @@ processor_settings:
     all_fields: true
     fields:
       - body
-      - title
       - field_description
-      - field_transcript_trad
-      - field_transcript_vo
-      - name
-      - field_workflow
       - field_genres
       - field_langues
       - field_synonyms
+      - field_transcript_trad
+      - field_transcript_vo
+      - field_workflow
+      - langcode
+      - language_with_fallback
+      - name
+      - title
     weights:
       preprocess_index: -20
       preprocess_query: -20
-  transliteration:
+  language_with_fallback: {  }
+  rendered_item: {  }
+  reverse_entity_references: {  }
+  tokenizer:
     all_fields: true
     fields:
       - body
-      - title
       - field_description
+      - field_genres
+      - field_langues
+      - field_synonyms
       - field_transcript_trad
       - field_transcript_vo
       - name
-      - field_workflow
+      - title
+    spaces: ''
+    overlap_cjk: 1
+    minimum_word_size: '3'
+    weights:
+      preprocess_index: -6
+      preprocess_query: -6
+  transliteration:
+    all_fields: true
+    fields:
+      - body
+      - field_description
       - field_genres
       - field_langues
       - field_synonyms
+      - field_transcript_trad
+      - field_transcript_vo
+      - field_workflow
+      - langcode
+      - language_with_fallback
+      - name
+      - title
     weights:
       preprocess_index: -20
       preprocess_query: -20
-  content_access:
-    weights:
-      preprocess_query: -30
 tracker_settings:
   default:
-    indexing_order: fifo
+    indexing_order: lifo
 options:
   index_directly: true
   cron_limit: 50

File diff suppressed because it is too large
+ 0 - 0
web/modules/custom/edlp_corpus/assets/dist/scripts/corpus.min.js


+ 2 - 2
web/modules/custom/edlp_corpus/assets/scripts/corpus.js

@@ -18,7 +18,7 @@
 (function($, Drupal, drupalSettings) {
 
   EdlpCorpus = function(){
-    var _activated = true;
+    var _activated = false;
     var _$body = $('body');
     var _$container = _$body;
     var _$canvas = $('<canvas id="corpus-map">').appendTo(_$container);
@@ -759,7 +759,7 @@
       console.log("_scene_props", _scene_props);
       _evolution_zone.left =
         left == 0
-        ? left+20 
+        ? left+20
         : Math.max(_scene_props.width/5, left+20);
       _evolution_zone.right =
         right == 0

+ 14 - 11
web/modules/custom/edlp_search/src/Controller/EdlpSearchController.php

@@ -150,10 +150,14 @@ class EdlpSearchController extends ControllerBase {
     $query->addConditionGroup($wf_condition_group);
 
     // Search for keys.
-    if (!empty($this->keys)) {
+    if (!empty($this->keys)) { // && strlen($this->keys) > 2
       // dpm($this->keys);
       $query->keys($this->keys);
     }
+    // else{
+    //   $this->matches = [];
+    //   return;
+    // }
 
 
     if(null !== $this->field_synonyms){
@@ -167,6 +171,7 @@ class EdlpSearchController extends ControllerBase {
     $result = $query->execute();
     $items = $result->getResultItems();
     // dpm($items);
+
     $this->matches = [];
     foreach ($items as $item) {
       // get the field from item
@@ -185,6 +190,7 @@ class EdlpSearchController extends ControllerBase {
       // dpm($fields);
       // get field content
       $field_text = $fields[0]->getText();
+      // $entity_id = $fields[0]->get('tid');
 
       // if content already in matches, skip item
       if( in_array($field_text, $this->matches) ){
@@ -192,6 +198,7 @@ class EdlpSearchController extends ControllerBase {
       }
 
       // add the item to the return list
+      // $matches_names = $field_text . '('.$entity_id.')';
       $this->matches[] = $field_text;
 
       // do not return more than 14 items
@@ -250,7 +257,6 @@ class EdlpSearchController extends ControllerBase {
 
     $response = new JsonResponse();
     $response->setData([
-      'test'=>'search results',
       'keys'=>$this->keys,
       'entries' => $this->entries,
       'entry_names' => $this->entry_names,
@@ -308,8 +314,12 @@ class EdlpSearchController extends ControllerBase {
     $parse_mode = \Drupal::getContainer()
         ->get('plugin.manager.search_api.parse_mode')
         ->createInstance('direct');
+    // $parse_mode->setConjunction('AND');
     $query->setParseMode($parse_mode);
 
+    // search in both languages (if not conditions will not work)
+    $query->setLanguages(array('fr','en'));
+
     // workflow
     $wf_condition_group = $query->createConditionGroup('OR');
     $wf_condition_group->addCondition('field_workflow', 'corpus_documents_publie', "=");
@@ -335,6 +345,8 @@ class EdlpSearchController extends ControllerBase {
       $query->addCondition('field_genres', $this->genres, "=");
     }
 
+    // TODO: locuteurs
+
     // entries
     $this->entry_names = [];
     if (!empty($this->entries)){
@@ -348,15 +360,6 @@ class EdlpSearchController extends ControllerBase {
       $query->addConditionGroup($entries_condition_group);
     }
 
-    // TODO: locuteurs
-
-    $current_langcode = \Drupal::languageManager()->getCurrentLanguage()->getId();
-    $query->setLanguages(array($current_langcode));
-
-    // $language = \Drupal::languageManager()->getCurrentLanguage()->getId();
-    // // $language =  \Drupal::languageManager()->getCurrentLanguage()->getName();
-    // $query->addCondition('search_api_language', $language);
-
     $result = $query->execute();
     $items = $result->getResultItems();
     // dpm($items);

Some files were not shown because too many files changed in this diff