在不同数据集中进行Lucene搜索

时间:2018-11-06 22:08:18

标签: java elasticsearch search indexing lucene

我一直在使用lucene来基于传入的数据(即基本上是表的内容)动态创建ram索引,其中任何信息都表示为文档,并附加引用了其元信息,例如table /列/值/类型。它运行良好且灵活,但是到目前为止,我的经理们决定扩展功能,以便搜索系统中所有的数据集,这些数据集是动态创建/更新的,ram索引显然不能再用于我们目前所拥有的方式,因为我们只是在某个时间点耗尽了内存。 在不对现有搜索引擎进行重大更改的情况下,以Lucene方式实现此目标的常用方法是什么?

这是用于创建ram索引的代码段

    ####################################################
    upstream dev {
        server 127.0.0.1://port// weight=1 fail_timeout=300s;
        keepalive 16;
      }
    ####################################################
    upstream l33t {
        server 127.0.0.1://port// weight=1 fail_timeout=300s;
        keepalive 16;
      }
    ####################################################
    upstream authserver {
        server 127.0.0.1://PORT// weight=1 fail_timeout=300s;
        keepalive 16;
      }


    #######################
    #  whereyougoing :80  #
    #######################

#nowhere..         you're going.... nowhere...

    ######################
    #   - FORCE HTTPS -  #
    ######################

    server {
        listen 80;
        server_name YOURSITE.COM;
        add_header Strict-Transport-Security max-age=2592000;
        rewrite ^/.*$ https://YOURSITE.COM permanent;
    }

    server {
        listen 80;
        server_name www.YOURSITE.COM;
        add_header Strict-Transport-Security max-age=2592000;
        rewrite ^/.*$ https://www.YOURSITE.COM permanent;
    }


    server {
        listen 80;
        server_name auth.YOURSITE.COM;
        add_header Strict-Transport-Security max-age=2592000;
        rewrite ^/.*$ https://auth.YOURSITE.COM permanent;
    }

    server {
        listen 80;
        server_name its.YOURSITE.COM;
        add_header Strict-Transport-Security max-age=2592000;
        rewrite ^/.*$ https://its.YOURSITE.COM permanent;
    }


    ######################################################
    #############  SSL SERVER starts here  ###############
    ######################################################

    server {

        listen 443 ssl http2 default_server;
        listen [::]:443 ssl http2 default_server;
        server_name YOURSITE.COM www.YOURSITE.COM auth.YOURSITE.COM its.YOURSITE.COM;
        root /var/www/wordpress;
        index index.php index.htm index.html;
        access_log /var/log/nginx/rocketstack_ssl_access.log;
        error_log /var/log/nginx/rocketstack_ssl_error.log;

    #######################################
    #            Lock it down             #
    #######################################

    # SSL certificate locations
        ssl_certificate /etc/letsencrypt/live/YOURSITE.COM/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/YOURSITE.COM/privkey.pem;

    # Exclusions
        include snippets/exclusions.conf;

    # Security
        include snippets/security.conf;
        include snippets/ssl.conf;

    # Fastcgi cache rules
        include snippets/fastcgi-cache.conf;
        include snippets/limits.conf;
        include snippets/nginx-cloudflare.conf;

    ############################################
    #             port-authority               #
    ############################################

    if (-d $request_filename) {
        rewrite [^/]$ $scheme://$http_host$uri/ permanent;
    }

    ############################################
    #                Locations                 #
    ############################################

        location / {
            try_files $uri $uri/  /index.php?$args;
        }

        location /FOO {
            alias /var/www/devl;
            index index.php index.html index.htm;
            try_files $uri $uri/               /index.php?$args;
            autoindex                          on;
        }

        location /BAR {

              proxy_set_header Origin           http://$host;
              proxy_set_header Host             $http_host:$server_port;
              proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
              proxy_set_header Upgrade          $http_upgrade;
              proxy_set_header Connection       $http_connection;
              proxy_http_version 1.1;
          }


    ################# Fastphp accelleration #############

        location ~ \.php$ {
            try_files $uri =404;
            include snippets/fastcgi-params.conf;
            fastcgi_pass unix:/run/php/php7.2-fpm.sock;

    # Skip cache based on rules in snippets/fastcgi-cache.conf.

            fastcgi_cache_bypass     $skip_cache;
            fastcgi_no_cache         $skip_cache;

    # Define memory zone for caching.

            fastcgi_cache rocketstack;

    # Define caching time.

            fastcgi_cache_valid 60m;

    #increase timeouts

            fastcgi_read_timeout 3000;
            fastcgi_connect_timeout 3000;
            fastcgi_send_timeout 3000;
            proxy_read_timeout 3000;
            proxy_connect_timeout 3000;
            proxy_send_timeout 3000;
            send_timeout 3000;

    # Flexible SSL to be used So the server can talk non-ssl internally

            proxy_set_header X-Forwarded-Host $host;
            proxy_set_header X-Forwarded-Server $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto https;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-NginX-Proxy true;
        }
    }

    ##############################################
    ###########    Server ends here    ###########
    ###########                        ###########
    ###########  Call upstream starts  ###########
    ###########                        ###########
    ##############################################



          #######################
          #     auth-serve      #
          #######################

    server {
        listen 9001 ssl;

    #############  Lock it down  ################

    # SSL certificate locations
        ssl_certificate /etc/letsencrypt/live/YOURSITE.COM/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/YOURSITE.COM/privkey.pem;

    # Exclusions

        include snippets/exclusions.conf;

    # Security

        include snippets/security.conf;
        include snippets/ssl.conf;

    # Fastcgi cache rules

        include snippets/fastcgi-cache.conf;
        include snippets/limits.conf;
        include snippets/nginx-cloudflare.conf;

    ###########  Send to Location upstream ##############

        location /authserver {
            proxy_redirect /*                 /$1;
            proxy_pass http://authserver/;
            proxy_set_header Origin           $host;
            proxy_set_header Host             $host:$server_port;
            proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
            proxy_set_header Upgrade          $http_upgrade;
            proxy_set_header Connection       $http_connection;
            proxy_http_version 1.1;
        }

这是用于搜索索引的代码段

final Analyzer analyzer = new StandardAnalyzer();
final Directory index = new RAMDirectory();
final IndexWriterConfig config = new IndexWriterConfig(Version.LATEST, analyzer);
try (final IndexWriter writer = new IndexWriter(index, config)) {

    addTableDocuments(tables, writer);
    addColumnDocuments(columns, writer);
    addValueDocuments(values, writer);
}

0 个答案:

没有答案