2016-05-27 3 views
0

バッチインサータに奇妙な問題があります。バッチインサータは正常に動作しますが、その場所からサーバーを起動すると、CYPHERはプロパティをフィルタできません。Neo4jバッチインサータ

クエリ"match(a) return a"はすべてのノードを返します。しかし、私は任意のプロパティに基づいてそれをフィルタリングしようとすると、それはすべての行を返しません。クエリmatch(a) where a.Name="Someone" return aは何も返しません。

SETコマンドを実行してプロパティを更新すると、それを正しくフィルタリングできます。インデックス問題のように見えますが、正確に把握することはできません。

 
**Output of - `match(a) return a` -** 

╒══════════════════════════════╕ 
│a        │ 
╞══════════════════════════════╡ 
│{}       │ 
├──────────────────────────────┤ 

│{Company: "Neo Technology", ye│ 
│ar: 2013, Name: "Kenny Bastani│ 
│"}       │ 
├──────────────────────────────┤ 
│{Company: "Neo Technology", ye│ 
│ar: 2010, Name: "Michael Hunge│ 
│r"}       │ 
├──────────────────────────────┤ 
│{Company: "Heroku", year: 2011│ 
│, Name: "James Ward"}   │ 
├──────────────────────────────┤ 
│{Name: "Someone"}    │ 
├──────────────────────────────┤ 
│{Company: "Doe.com", year: "ni│ 
│netynine", Name: "John"}  │ 
└────── 
 
**File -** 

    Name,Company,year 

    "Kenny Bastani","Neo Technology",2013 

    "Michael Hunger","Neo Technology",2010 

    "James Ward","Heroku",2011 

    "Someone",, 

    "John","Doe.com","ninetynine" 

 
**Batch Inserter-** 

    public void importNodes() throws IOException { 
      FileInputStream fis = new FileInputStream(
        "E:\\neo4j\\CSV_Import\\01.csv"); 
      InputStreamReader isr = new InputStreamReader(fis); 
      BufferedReader br = new BufferedReader(isr); 
      String line = null; 

      File storeDir = new File("E:\\neo4j\\test_data1"); 
      FileUtils.deleteRecursively(storeDir); 


      BatchInserter neoBatchInserter = BatchInserters.inserter(storeDir); 

      Map properties = new HashMap(); 
      ArrayList headerMap = new ArrayList(); 

      BatchInserterIndexProvider indexProvider = new LuceneBatchInserterIndexProvider(
        neoBatchInserter); 

      BatchInserterIndex autoIndex = indexProvider.nodeIndex("node_auto_index", 
        MapUtil.stringMap("type", "exact")); 

      autoIndex.setCacheCapacity("Name", 10000); 

      neoBatchInserter.createDeferredSchemaIndex(Labels.Person).on("Name").create(); 

      String propertyName = ""; 

      boolean headerFlag = true; 

      int counter = 0; 

      while ((line = br.readLine()) != null) { 

       String[] values = line.split(","); 

       for (String value : values) { 

        if (headerFlag) { 

         headerMap.add(value); 

        } else { 

         propertyName = headerMap.get(counter); 
         properties.put(propertyName, value); 

        } 

        counter++; 
       } 

       System.out.println("New Node - " + properties); 
       long node = neoBatchInserter.createNode(properties, Labels.Person); 
       autoIndex.add(node, properties); 
       autoIndex.flush(); 

       counter = 0; 
       properties.clear(); 
       headerFlag = false; 

      } 

      indexProvider.shutdown(); 
      neoBatchInserter.shutdown(); 
     } 
+0

node_auto_indexは必要ありません。 –

+0

'' 'を削除するか、OpenCSVのような適切なCSVパーサーを使用するか、neo4j-importツールをうまく使用する必要があります。 –

答えて

0

それがインデックスの問題であれば、インデックスを削除して再作成すると、それを修正することがあります。

+0

これは実際には役に立たないでしょう私はインサータコードでどこが間違っているのか把握する必要があります。 –