lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davers <dboych...@improvementdirect.com>
Subject Re: SEVER error when stopping tomcat using solr webapp
Date Thu, 13 Dec 2012 19:09:08 GMT
The only custom code I have are 3 custom transformers for my DIH.

Here is the code.

package org.build.com.solr;

/**
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import org.apache.solr.handler.dataimport.Context;
import org.apache.solr.handler.dataimport.Transformer;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class CategoriesTransformer extends Transformer {
  
  public Object transformRow(Map<String, Object> row, Context context) {
    int index = 0;
    Object tf = row.get("categories");
    
    if (tf != null) {
      String[] arr = ((String) tf).split(",");
      String tempKey = "";
      
      for (int i = 0; i < arr.length; i++) {
        if (arr[i].length() > 0) {
          index = arr[i].indexOf(':');
          
          tempKey = "categories_" + arr[i].substring(0, index) + "_i";
              if (row.containsKey(tempKey))
              {
                List<String> tempArrayList =
(ArrayList<String>)row.get(tempKey);
                tempArrayList.add(arr[i].substring(index+1,
arr[i].length()));
                row.put(tempKey, tempArrayList);
              } else {
                List<String> tempArrayList = new ArrayList<String>();
                tempArrayList.add(arr[i].substring(index+1,
arr[i].length()));
                row.put(tempKey, tempArrayList);
              }
        }
      }
      
      row.remove("categories");
    }
    return row;
  }
}

package org.build.com.solr;

/**
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import org.apache.solr.handler.dataimport.Context;
import org.apache.solr.handler.dataimport.Transformer;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class FacetsTransformer extends Transformer {
  
  public Object transformRow(Map<String, Object> row, Context context) {
    Object tf = row.get("facets");
        if (tf != null) {
          if (tf instanceof List) {
            List list = (List) tf;
            String tempKey = "";
            for (Object o : list) {
              String[] arr = ((String) o).split("=");
              if (arr.length == 3) {
                tempKey = arr[0].replaceAll("[^A-Za-z0-9]", "") + "_" +
arr[1];
                if (row.containsKey(tempKey))
                {
                  List<String> tempArrayList =
(ArrayList<String>)row.get(tempKey);
                  tempArrayList.add(arr[2]);
                  row.put(tempKey, tempArrayList );
                } else {
                  List<String> tempArrayList = new ArrayList<String>();
                  tempArrayList.add(arr[2]);
                  row.put(tempKey, tempArrayList);
                }
              }
            }
          } else {
            String[] arr = ((String) tf).split("=");
            if (arr.length == 3) row.put(arr[0].replaceAll("[^A-Za-z0-9]",
"") + "_" + arr[1], arr[2]);
          }
          row.remove("facets");
        }
        return row;
  }
}

package org.build.com.solr;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.solr.handler.dataimport.Context;
import org.apache.solr.handler.dataimport.Transformer;

/**
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

public class PricebookTransformer extends Transformer {
  
  public Object transformRow(Map<String, Object> row, Context context) {
    Object tf = row.get("prices");
    if (tf != null) {
      String[] pricebookData = ((String) tf).split(":");
      if (pricebookData.length == 2) {
        if (pricebookData[0].length() > 0 && pricebookData[1].length() > 0)
{
          String[] pricebooks = pricebookData[0].split(",");
          String[] costs = pricebookData[1].split("\\^");
          String[] arr;
          String defaultPrice = "0";

          for (int i = 0; i < costs.length; i++) {
            arr = costs[i].split("=");
            if (Integer.parseInt(arr[0]) == 1) {
              row.put("price", arr[1]);
              defaultPrice = arr[1];
            }

            row.put("pricebook_" + arr[0] + "_numeric", arr[1]);
          }

          for (int i = 0; i < pricebooks.length; i++) {
            if (!row.containsKey("pricebook_" + pricebooks[i] + "_numeric"))
              row.put("pricebook_" + pricebooks[i] + "_numeric",
defaultPrice);
          }

        }
      }

      row.remove("prices");
    }
    return row;
  }

}



--
View this message in context: http://lucene.472066.n3.nabble.com/SEVER-error-when-stopping-tomcat-using-solr-webapp-tp4026576p4026808.html
Sent from the Solr - User mailing list archive at Nabble.com.

Mime
View raw message