5

Solrでは、stored = "true"のフィールドがスキーマにあり、そのフィールドに関連付けられているアナライザーを変更した場合、すべてのドキュメントのインデックスを再作成せずに、このフィールドだけを更新できますか?これは、元のデータソースに戻らずに、新しいアナライザーでフィールドの「保存された」値を使用して実行できますか?

4

3 に答える 3

1

男、私はあなたのコードを最適化しました。

    ...
    while (iter.hasNext()) {
        ...
        //server.deleteById(id) ;
        //server.commit() ;

        Collection<SolrInputDocument> docs = new ArrayList<SolrInputDocument>();
        docs.add(inputdoc) ;
        server.add(docs) ;
        // server.commit() ;
    }
    server.commit() ;
于 2010-12-03T09:48:36.310 に答える
0

このSolrのIBMチュートリアルをチェックしてください

于 2010-12-24T18:40:17.887 に答える
0

SolrJを使用する方法を見つけました。

        SolrQuery query = new SolrQuery();

        query.setQuery( "whatever_by_id" );

        QueryResponse rsp;

        rsp = server.query(query);

        Iterator<SolrDocument> iter = rsp.getResults().iterator();

        while (iter.hasNext()) {
            SolrDocument resultDoc = iter.next();
            String id = (String) resultDoc.getFieldValue("oid"); //id is the uniqueKey field

            SolrInputDocument inputdoc = new SolrInputDocument() ;
            for( Map.Entry<String, Object> f : resultDoc.entrySet()) {
                inputdoc.setField(f.getKey(), f.getValue()) ;
            }

            server.deleteById(id) ;
            server.commit() ;

            Collection<SolrInputDocument> docs = new ArrayList<SolrInputDocument>();
            docs.add(inputdoc) ;
            server.add(docs) ;

            server.commit() ;
        }

「新しい」inputdoc (古い resultDoc のコピー) を追加すると、スキーマで変更した新しいアナライザーを使用してインデックスを作成します。あまりエレガントではありませんが、機能します。

于 2010-10-27T22:29:22.517 に答える