Solr with Django-Haystack:'无法创建测试人员'

时间:2017-07-12 15:24:40

标签: django shell solr django-haystack

我正在尝试使用solr创建一个带有django haystack的搜索引擎。到目前为止,我按照下面的文档在我的服务器上安装了solr-6.6.0。

http://django-haystack.readthedocs.io/en/master/installing_search_engines.html#solr

但是使用命令

./bin/solr create -c tester -n basic_config

我一直收到错误:

Failed to determine the port of a local Solr instance, cannot create tester!

可能是什么问题?

2 个答案:

答案 0 :(得分:0)

您可以使用以下命令:

function validateForm() {
    if (Math.floor(Math.random() * 2) == 1) {
        console.log('success');
        $('#modal-form').modal('hide');
        return;
    }
    console.log('failure');
    return false;
}

$(document).ready(function () {
    console.log('ready')
    $('#submit-btn').submit(function (event) {
        event.preventDefault();
        let $form = this,
            $submit = $form.find('button[type="submit"]'),
            email = $form.find('#email'),
            pwd = $form.find('#pwd');

        if (validateForm(email, pwd, text)) {
            $submit.text('wrong');
            return false;
        }
        $submit.attr("disabled", true);
    });
});

你的solr将在127.0.0.1:8983上运行

创建核心:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Form</title>
  <script src="https://code.jquery.com/jquery-3.2.1.js"
          integrity="sha256-DZAnKJ/6XZ9si04Hgrsxu/8s717jcIzLy3oi35EouyE=" crossorigin="anonymous"></script>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
        integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  <link rel="stylesheet" href="styles.css">
  <script src="index.js"></script>
</head>
<body>
<div class="container">
  <button type="button" class="click-btn btn btn-info btn-lg" data-toggle="modal" data-target="#modal-form">Click
  </button>
  <div class="modal fade" id="modal-form" role="dialog">
    <div class="modal-dialog">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Form</h4>
      </div>
      <div class="modal-body">
        <form id="form" class="form-horizontal">
          <div class="form-group">
            <label for="email">Email address:</label>
            <input type="email" class="form-control" id="email">
          </div>
          <div class="form-group">
            <label for="pwd">Password:</label>
            <input type="password" class="form-control" id="pwd">
          </div>
        </form>
      </div>
      <div class="modal-footer">
        <button id="submit-btn" type="submit" class="btn btn-default">Submit</button>
      </div>
    </div>
  </div>
</div>
</body>
</html>

答案 1 :(得分:0)

要使用 “solr” 用户创建核心:

sudo -u solr ./bin/solr create -c mycore

对于错误:“无法确定本地 Solr 实例的端口,无法创建测试器!” 您需要停止并重新启动您的 Solr 服务

<块引用>

sudo service solr stop | sudo service solr start