Examples of NutchBean


Examples of org.apache.nutch.searcher.NutchBean

    throws IOException {
    this.queriesFile = queriesFile;
    this.numThreads = numThreads;
    this.showTimes = showTimes;
    this.conf = NutchConfiguration.create();
    this.bean = new NutchBean(conf);
  }
View Full Code Here

Examples of org.apache.nutch.searcher.NutchBean

  private ServletContextServiceLocator(ServletContext servletContext) {
    this.servletContext = servletContext;
    config = NutchConfiguration.get(servletContext);
    repository = PluginRepository.get(config);
    try {
      bean = new NutchBean(config);
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
View Full Code Here

Examples of org.apache.nutch.searcher.NutchBean

  public void nutchPerform(ComponentContext tileContext,
      HttpServletRequest request, HttpServletResponse response,
      ServletContext servletContext) throws ServletException, IOException {

    ServiceLocator locator = getServiceLocator(request);
    NutchBean bean = locator.getNutchBean();

    LOG.info("Cache request from " + request.getRemoteAddr());

    Hit hit = new Hit(Integer.parseInt(request.getParameter("idx")),
                      Integer.parseInt(request.getParameter("id")));

    HitDetails details = bean.getDetails(hit);
    String id = "idx=" + hit.getIndexNo() + "&id=" + hit.getIndexDocNo();

    Metadata metaData = bean.getParseData(details).getContentMeta();

    String content = null;
    String contentType = (String) metaData.get(Metadata.CONTENT_TYPE);


    if (contentType.startsWith("text/html")) {
      // FIXME : it's better to emit the original 'byte' sequence
      // with 'charset' set to the value of 'CharEncoding',
      // but I don't know how to emit 'byte sequence' in JSP.
      // out.getOutputStream().write(bean.getContent(details)) may work,
      // but I'm not sure.
      String encoding = (String) metaData.get("CharEncodingForConversion");
      if (encoding != null) {
        try {
          content = new String(bean.getContent(details), encoding);
        } catch (UnsupportedEncodingException e) {
          //fallback to configured charset
          content = new String(bean.getContent(details), locator
              .getConfiguration().get("parser.character.encoding.default"));
        }
      } else {
        //construct String with system default encoding
        content = new String(bean.getContent(details));
      }
    }

    // page content
    request.setAttribute("content", content);
View Full Code Here

Examples of org.apache.nutch.searcher.NutchBean

  public void nutchPerform(ComponentContext tileContext,
      HttpServletRequest request, HttpServletResponse response,
      ServletContext servletContext) throws ServletException, IOException {
    ServiceLocator locator = getServiceLocator(request);
    NutchBean bean = locator.getNutchBean();

    LOG.info("anchors request from " + request.getRemoteAddr());
    Hit hit = new Hit(Integer.parseInt(request.getParameter("idx")), Integer
        .parseInt(request.getParameter("id")));

    HitDetails details = bean.getDetails(hit);

    String[] anchors = bean.getAnchors(details);
    ArrayList anchorVector = new ArrayList();
    if (anchors != null) {
      for (int i = 0; i < anchors.length; i++) {
        anchorVector.add(Entities.encode(anchors[i]));
      }
View Full Code Here

Examples of org.apache.nutch.searcher.NutchBean

  public void nutchPerform(ComponentContext tileContext,
      HttpServletRequest request, HttpServletResponse response,
      ServletContext servletContext) throws ServletException, IOException {

    ServiceLocator locator = getServiceLocator(request);
    NutchBean bean = locator.getNutchBean();

    Hit hit = new Hit(Integer.parseInt(request.getParameter("idx")), Integer
        .parseInt(request.getParameter("id")));
    HitDetails details = bean.getDetails(hit);
    Query query = Query.parse(request.getParameter("query"), locator
        .getConfiguration());

    // put explanation and hitDetails into request so view can access them
    request.setAttribute("explanation", bean.getExplanation(query, hit));
    request.setAttribute("hitDetails", details.toHtml());
    request.setAttribute("query", query);
  }
View Full Code Here

Examples of org.apache.nutch.searcher.NutchBean

  }

  public static NutchBean get(ServletContext app, Configuration conf)
    throws IOException
  {
    NutchBean bean = (NutchBean)app.getAttribute("nutchBean");
   
    if (bean == null) {   
      LOG.info("creating new bean");     
     
      // Get the NutchwaxBean in there.
View Full Code Here

Examples of org.apache.nutch.searcher.NutchBean

      System.exit(-1);
    }

    Configuration conf = NutchwaxConfiguration.getConfiguration();
   
    NutchBean bean = new NutchwaxBean(conf);
   
    Query query = Query.parse(args[0], conf);
   
    Hits hits = bean.search(query, 10);
    System.out.println("Total hits: " + hits.getTotal());
   
    int length = (int)Math.min(hits.getTotal(), 10);
   
    Hit[] show = hits.getHits(0, length);
   
    HitDetails[] details = bean.getDetails(show);
   
    Summary[] summaries = bean.getSummary(details, query);

    for (int i = 0; i < hits.getLength(); i++)
    {
      System.out.println(" "+i+" "+ details[i] + "\n" + summaries[i]);
    }
View Full Code Here

Examples of org.apache.nutch.searcher.NutchBean

      if (args.length==3 && args[2]!=null) {
        blacklistFile = new File(args[2]);
      }

      Configuration conf = NutchwaxConfiguration.getConfiguration();
      NutchBean bean = new NutchBean(conf, directory, blacklistFile);
      int numHandlers=conf.getInt(Global.NUMBER_HANDLERS, -1);
        boolean ipcVerbose=conf.getBoolean(Global.IPC_VERBOSE, false);

      org.apache.hadoop.ipc.Server server = RPC.getServer(bean,
          "0.0.0.0", port, numHandlers, ipcVerbose, conf);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.