0

这是我从 mongoDB 导入后的文档:

    documents": [
    {
      "uid": [
        1
      ],
      "body": [
        ""
      ],
      "field_section": [
        {
          "nid": "3"
        }
      ],
      "node_panels": [
        {
          "use_node_panel": false
        }
      ],
      "field_urltitle": [
        {
          "value": null
        }
      ],
      "field_test_content": [
        {
          "value": null
        }
      ],
      "type": [
        "book"
      ],
      "changed": [
        1354017880
      ],
      "nodewords_nodetype_override": [
        false
      ],
      "field_content_extract": [
        {
          "nid": null
        }
      ],
      "created": [
        1320142582
      ],
      "taxonomy": [
        {
          "796": {
            "tid": 796,
            "vid": 2,
            "name": "Roman Français",
            "description": "",
            "weight": "0"
          }
        }
      ],
      "vid": [
        595023
      ],
      "field_comment": [
        {
          "value": null
        }
      ],
      "field_description": [
        {
          "value": "<p>\"Je ne sais pas, écrit l'auteur, si quelqu'un avant moi a jamais tenté de réunir la totalité des souvenirs qu'il a gardés de ses dix ou onze premières années. J'ai cherché à les reproduire non seulement sous leur forme objective d'actes, d'attitudes ou de jugements, mais aussi avec la saveur subjective que ces faits eurent pour moi à l'époque. Car ce qui importe le plus, ici, ce n'est pas tant l'exactitude historique des faits rapportés (encore que je me sois efforcé de la respecter), c'est leur retentissement, la trace qu'ils laissent dans la vie intérieure de l'enfant, puis dans celle de l'adulte, jusqu'à sa mort sans doute\". </p>",
          "format": "7"
        }
      ],
      "field_content_continue_with": [
        {
          "nid": null
        }
      ],
      "field_content_celebrity": [
        {
          "nid": "591932",
          "type": "50"
        }
      ],
      "field_content_day": [
        {
          "value": null,
          "timezone": "Europe/Paris",
          "timezone_db": "Europe/Paris",
          "date_type": "datestamp"
        }
      ],
      "field_evene_modified": [
        {
          "value": null
        }
      ],
      "field_content_video": [
        {
          "nid": null
        }
      ],
      "field_fnac_url": [
        {
          "url": "http://livre.fnac.com/a4069141/Quentin-Jacares-Le-passe-interieur",
          "title": null,
          "attributes": []
        }
      ],
      "format": [
        0
      ],
      "log": [
        "Created/updated by FeedsNodeProcessor"
      ],
      "field_external_category": [
        {
          "value": "a:2:{i:0;s:23:\"Littérature française\";i:1;s:0:\"\";}"
        }
      ],
      "field_publication_date": [
        {
          "value": 1320102000,
          "timezone": "Europe/Paris",
          "timezone_db": "Europe/Paris",
          "date_type": "datestamp"
        }
      ],
      "picture": [
        "files/user_pictures/picture-1.png"
      ],
      "field_content_more": [
        {
          "nid": null
        }
      ],
      "field_image": [
        {
          "fid": "200052",
          "uid": "1",
          "filename": "591933.gif",
          "filepath": "files/book/591933.gif",
          "filemime": "image/gif",
          "filesize": "33725",
          "status": "1",
          "timestamp": "1320142582",
          "origname": "decitre-import.gif",
          "list": null,
          "data": []
        }
      ],
      "field_selection": [
        {
          "value": null
        }
      ],
      "promote": [
        1
      ],
      "last_comment_timestamp": [
        1320142586
      ],
      "teaser": [
        ""
      ],
      "field_content_anecdote": [
        {
          "nid": null
        }
      ],
      "revision_timestamp": [
        1354017880
      ],
      "language": [
        ""
      ],
      "comment": [
        2
      ],
      "field_page_number": [
        {
          "value": 293
        }
      ],
      "page_title": [
        false
      ],
      "field_ads_keywords": [
        {
          "value": null
        }
      ],
      "data": [
        "a:5:{s:14:\"picture_delete\";i:0;s:14:\"picture_upload\";s:0:\"\";s:13:\"form_build_id\";s:37:\"form-195606921d7a71b9a51bf3bcdc018f38\";s:5:\"fbuid\";s:15:\"100000792647737\";s:9:\"nodewords\";a:9:{s:8:\"abstract\";a:1:{s:5:\"value\";s:0:\"\";}s:9:\"canonical\";a:1:{s:5:\"value\";s:0:\"\";}s:9:\"copyright\";a:1:{s:5:\"value\";s:0:\"\";}s:11:\"description\";a:1:{s:5:\"value\";s:0:\"\";}s:8:\"keywords\";a:1:{s:5:\"value\";s:0:\"\";}s:13:\"revisit-after\";a:1:{s:5:\"value\";s:1:\"1\";}s:6:\"robots\";a:2:{s:5:\"value\";a:6:{s:9:\"noarchive\";i:0;s:8:\"nofollow\";i:0;s:7:\"noindex\";i:0;s:5:\"noodp\";i:0;s:9:\"nosnippet\";i:0;s:6:\"noydir\";i:0;}s:11:\"use_default\";i:0;}s:8:\"dc.title\";a:1:{s:5:\"value\";s:0:\"\";}s:8:\"location\";a:2:{s:8:\"latitude\";s:0:\"\";s:9:\"longitude\";s:0:\"\";}}}"
      ],
      "field_external_id": [
        {
          "value": 9782310010054
        }
      ],
      "field_publication_first": [
        {
          "value": null,
          "timezone": "Europe/Paris",
          "timezone_db": "Europe/Paris",
          "date_type": "datestamp"
        }
      ],
      "field_prize": [
        {
          "nid": null,
          "label_1": "",
          "label_2": ""
        }
      ],
      "field_content_critique": [
        {
          "nid": null
        }
      ],
      "field_book_citation": [
        {
          "nid": null
        }
      ],
      "title": [
        "Le passé intérieur"
      ],
      "_id": [
        "org.bson.types.ObjectId:50b4aca6a6937d876782cbc3"
      ],
      "field_fnac_id": [
        {
          "value": null
        }
      ],
      "name": [
        "admin"
      ],
      "path": [
        "livres/livre/quentin-jacares-le-passe-interieur-591933.php"
      ],
      "field_isbn": [
        {
          "value": 9782310010054
        }
      ],
      "field_price": [
        {
          "value": "20.72"
        }
      ],
      "revision_uid": [
        0
      ],
      "tnid": [
        0
      ],
      "field_author_v2": [
        {
          "value": null
        }
      ],
      "field_subtitle": [
        {
          "value": "Une enfance dans la Belgique d'avant la guerre"
        }
      ],
      "field_label": [
        {
          "nid": "120600"
        }
      ],
      "comment_count": [
        0
      ],
      "nid": [
        591933
      ],
      "moderate": [
        0
      ],
      "field_site": [
        {
          "url": null,
          "title": null,
          "attributes": false
        }
      ],
      "field_v2_full": [
        {
          "value": null
        }
      ],
      "sticky": [
        0
      ],
      "field_v2_id": [
        {
          "value": null
        }
      ],
      "translate": [
        0
      ],
      "field_content_photo": [
        {
          "nid": null
        }
      ],
      "opengraph_meta": [
        {
          "title": "",
          "description": "",
          "image": "http://www.evene.fr/sites/all/themes/evene/images/logos/logo-evene.png",
          "type": "",
          "url": "",
          "latitude": "",
          "longitude": "",
          "street-address": "",
          "locality": "",
          "region": "",
          "postal-code": "",
          "country-name": "",
          "email": "",
          "phone_number": "",
          "fax_number": "",
          "site_name": "Evene.fr"
        }
      ]
    }
  ]

我希望配置为使用键和值索引所有字段。

我试过

<field name="field_description" type="text" indexed="true" stored="true" multiValued="true"/>

但是对于带有子键的对象,结果是空的。

结果 :

uid : 1 
body : 
spell : Le passé intérieur 
body_exact : 
type : book 
vid : 595023 
picture : files/user_pictures/picture-1.png 
teaser : 
title : Le passé intérieur 
title_exact : Le passé intérieur 
title_exact_ : Le passé intérieur 
_id : 50b4aca6a6937d876782cbc3 
path : livres/livre/quentin-jacares-le-passe-interieur-591933.php 
comment_count : 0 
nid : 591933 
_version_ : 1438259731338625024 
timestamp : Wed Jun 19 10:42:45 CEST 2013 
score : 1.0

你有解决办法吗

4

2 回答 2

0

考虑到您提供的示例,您似乎将 mongoDB 导出为 JSON 格式。因此,如果您想将 JSON 导入 Solr,默认情况下它不会处理嵌套值。您需要使用正确的声明才能使其正常工作。例如,在您的示例中,您需要 field_description 字段具有以下格式:

{
"field_description":{
  "value":"Je ne sais pas, ecrit l'auteur, si quelqu'un avant moi a jamais tente de reunir la totalite des souvenirs qu'il a gardzs de ses dix ou onze premieres annees.",
  "format":7
} }

如果您不使用 JSON 格式,而是使用另一个导入器用于 mongoDB/Solr 连接,请说明它是哪一个,以便我可以进一步帮助您。

于 2013-06-26T06:25:47.850 回答
0

一个解法:

为每一行使用带有 javascript 的转换器

数据配置:

<dataSource name="EveneMongo" type="MongoDataSource" database="evene" />
 <document name="node">
  <entity name="livre" processor="MongoEntityProcessor"
   query="{'status':1, 'type':'book'}"
   collection="node"
   datasource="EveneMongo"
   transformer="script:book1">
      <filed column="_id" name="_id" mongoField="nid" />
      <entity name="livre_label"
              processor="MongoEntityProcessor"
              onError="continue"
              query="{'nid': ${livre.field_label_nid} }"

              collection="node"
              datasource="EveneMongo"
              transformer="script:book2">
   </entity
 </document>
</dataConfig>

和脚本 js 在同一个文档上:

<script><![CDATA[

           function book1(row)
           {
                if(row.get('taxonomy') !== null)
                {
                    var taxo = JSON.parse(row.get('taxonomy'))

                    for(var i in taxo) {
                        if(taxo[i].name !== null  && taxo[i].vid !== null)
                        {
                            if(taxo[i].vid == 2)
                            {
                                row.put('taxonomy_names',taxo[i].name);
                            }
                        }
                    }
                }
            }

            function book2()
            {

            //...

            }
]]></script>
于 2013-06-28T11:01:36.147 回答