小编Nag*_*Nag的帖子

如何查看Lucene索引

我正在尝试学习和理解 lucene 是如何工作的,lucene 索引里面有什么。基本上我想看看数据在 lucene 索引中是如何表示的?

我用作lucene-core 8.6.0依赖项

下面是我非常基本的 Lucene 代码

    private Document create(File file) throws IOException {
        Document document = new Document();

        Field field = new Field("contents", new FileReader(file), TextField.TYPE_NOT_STORED);
        Field fieldPath = new Field("path", file.getAbsolutePath(), TextField.TYPE_STORED);
        Field fieldName = new Field("name", file.getName(), TextField.TYPE_STORED);

        document.add(field);
        document.add(fieldPath);
        document.add(fieldName);

        //Create analyzer
        Analyzer analyzer = new StandardAnalyzer();

        //Create IndexWriter pass the analyzer

        Path indexPath = Files.createTempDirectory("tempIndex");
        Directory directory = FSDirectory.open(indexPath);
        IndexWriterConfig indexWriterCOnfig = new IndexWriterConfig(analyzer);
        IndexWriter iwriter = new IndexWriter(directory, …
Run Code Online (Sandbox Code Playgroud)

lucene luke

7
推荐指数
1
解决办法
8377
查看次数

如何将反应事件处理程序移动到单独的文件,导出然后导入以在多个不同的功能组件中重用?

我有一个 React 功能组件,它打印一个在单击按钮时递增或递减的计数器编号。下面是我的函数

我正在使用反应版本:^16.13.1

export default function  Counter(){
    const [count, setCount] = useState(0);

    const increment = () => {
        //more logic here ..
        setCount(count + 1);
    }
    const decrement = () => {
        //more logic here ..
        setCount(count !== 0 ? count - 1 : 0);
    }
    return (
        <div>
          <p>You clicked {count} times</p>
          <button onClick={() => increment()}>Increment SO</button>
          <button onClick={() => decrement()}>Decrement SO</button>
        </div>
      );
} 
Run Code Online (Sandbox Code Playgroud)

我想分离事件处理程序逻辑,包括将状态设置到单独的文件中并将其导出..如下所示

import React, { useState } from 'react';

const Increment = () => …
Run Code Online (Sandbox Code Playgroud)

reactjs react-hooks

4
推荐指数
1
解决办法
2224
查看次数

标签 统计

lucene ×1

luke ×1

react-hooks ×1

reactjs ×1