小编tpt*_*cat的帖子

全文索引缓慢.寻找替代品

我有一张桌子,我已经创建了一个全文目录.该表只有6000多行.我在索引中添加了两列.第一个可以被认为是排序的唯一标识符,第二个可以被认为是该项目的内容(我的表中 11个其他列不是全文目录的一部分).以下是几行的示例:

TABLE: data_variables
ROW    unique_id    label
1      A100d1       Personal preference of online shopping sites
2      A100d2       Shopping behaviors for adults in household
Run Code Online (Sandbox Code Playgroud)

在我前端的Web应用程序中,我有一个文本框,用户可以输入该文本框以获取与他们在UNIQUE IDLABEL列中搜索的任何术语匹配的项目列表.因此,例如,如果用户键入shoa100然后列表将填充上面的两个行.如果他们键入,behav则列表将仅填充上面的第2行.

这是通过每个上面的Ajax请求完成的keyup.PHP在SQL服务器上调用存储过程,如下所示:

SELECT TOP 50 dv.id, dv.id + ': ' + dv.label, 
              dv.type_id, dv.grouping, dv.friendly_label
FROM          data_variables dv
WHERE         (CONTAINS((dv.unique_id, dv.label), @search))
Run Code Online (Sandbox Code Playgroud)

(@search是传递给存储过程的用户的文本.)

我注意到这变得非常缓慢,特别是当我没有TOP 50在查询中使用时.

我正在寻找的方法是直接在SQL Server上加速,或者放弃全文索引的想法,并使用jQuery在客户端搜索可搜索项目的数组.我看了一下jQuery AutoComplete的东西以及其他一些用于AutoComplete的jQuery插件,但还没有尝试模拟任何东西.这将是我的下一步,但我想先在这里查看,看看我会得到什么建议.

提前致谢.

performance jquery full-text-search autocomplete sql-server-2008

11
推荐指数
3
解决办法
1730
查看次数

iOS/Xcode:针对应用内购买的Debug,Ad Hoc和Release*的并发版本*

我已经按照这个教程,让我的应用程序有建立的DEBUG,ADHOC测试(我的测试用户),和RELEASE.除了我的应用内购买,一切都很好.

Bundle ID的设置是:

  • 调试: com.mycompany.myproduct.debug
  • 特设: com.mycompany.myproduct.adhoc
  • 发布: com.mycompany.myproduct

(RELEASEID与此新设置之前的ID相同.

由于此方法Bundle ID根据构建进行更改,因此应用程序内购买与Bundle ID我运行应用程序时的特定内容相关联,DEBUG或者ADHOC当我调用时,我的产品标识符返回为无效requestProductsWithCompletionHandler.

我尝试添加新的应用程序内购买产品,Bundle ID如下所示:com.mycompany.myproduct.debug.iapname但由于应用程序内购买与单个捆绑ID相关联,因此不起作用.

我的问题是:为了完成我想要完成的任务,我是否必须在iTunes Connect中为每个新的Bundle ID创建2个新应用程序,然后为每个Build添加应用程序内购买产品组态?或者,还有另一种方法可以实现我想要完成的任务吗?

xcode in-app-purchase buildconfiguration ios bundle-identifier

8
推荐指数
1
解决办法
916
查看次数

API/SPA的用户注册

我正在创建一个API和一个单独的前端应用程序,它将使用所述API.在我的特殊情况下,我使用Laravel Passport作为我的API,并使用一些VueJS作为我的前端应用程序.

为了让用户创建一个帐户,用户必须使用API​​上的POSTroute(/oauth/token),这需要client_secret传递(https://laravel.com/docs/5.3/passport#password-grant-tokens).

我看到的唯一选择是:

  1. 具有client_secret发送,从我的前端应用程序的标题.但是,将此令牌放在公开状态似乎并不聪明.
  2. 根本不需要client_secret.这似乎没有比选项1好多少.
  3. 在我的前端应用程序上有一个动态页面,可以安全地存储client_secret然后将其发送到API.虽然这显然是最安全的,但似乎部分地破坏了完全静态前端(SPA)的目的.

这种方法的最佳实践是什么?我已经搜索了如何通过API和SPA处理这个问题,但我没有找到任何指向正确方向的东西.

csrf jwt laravel vue.js laravel-passport

7
推荐指数
2
解决办法
1493
查看次数

按另一列分组的一列的最低值排序

这在标题中很难解释,但这里有一张表:

CATEGORY_ID   COUNT   GROUPING
1             130     H
2              54     B
3             128     C
4              70     D
5              31     E
6              25     F
7              64     A
8              59     F
9              66     B
10             62     E
11            129     C
12             52     G
13             27     A
14            102     A
15            101     C
Run Code Online (Sandbox Code Playgroud)

我正在尝试编写一个查询来获取TOP 5 CATEGORY_ID's,首先按整体排序COUNT,然后基于该组使用该组中的其他CATEGORY_ID人,而不管他们是谁COUNT.所以,如果我想TOP 5基于这个规则(我可能解释得很差),我的结果将是:

CATEGORY_ID   COUNT   GROUPING
6             25      F <-- THE LOWEST COUNT OVERALL
8             59      F <-- THE NEXT …
Run Code Online (Sandbox Code Playgroud)

t-sql sql-server group-by sql-order-by ranking

2
推荐指数
1
解决办法
644
查看次数

Laravel 4和Eloquent:检索所有记录和所有相关记录

我有两个班:ArtistInstrument.每个人都Artist可以玩一个或多个Instrument.并且每个Instrument都可以分配给一个或多个Artists.所以,我已经设置了以下类:

Artist.php

public function instruments() {
    return $this->belongsToMany('App\Models\Instrument');
}
Run Code Online (Sandbox Code Playgroud)

Instrument.php

public function artists() {
    return $this->belongsToMany('\App\Models\Artist');
}
Run Code Online (Sandbox Code Playgroud)


然后我有三个数据库表:

artists: id, firstname, lastname, (timestamps)
instruments: id, name
artist_instrument: id, artist_id, instrument_id
Run Code Online (Sandbox Code Playgroud)


我能够成功找回一位艺术家及其相关乐器,如下所示:

ArtistController.php

$artist = Artist::find($artist_id);
$instruments = $artist->instruments()->get();
return \View::make('artists')->with('artists', $artists)->with('instruments', $instruments);
Run Code Online (Sandbox Code Playgroud)

我有3个问题:

  1. 在我看来,我可以输出$artist像:

    {{ $artist->firstname }}
    
    Run Code Online (Sandbox Code Playgroud)

    我可以迭代$instruments:

    @foreach ($instruments as $instrument)
        <h2>{{ $instrument->name }}</h2>
    @endforeach
    
    Run Code Online (Sandbox Code Playgroud)

    但是有可能迭代$artist(我知道只有一个 - 见#2)并且每次$artist …

orm foreign-key-relationship laravel eloquent

2
推荐指数
1
解决办法
8886
查看次数